Exemple #1
0
def run(cmd, args, flags, io, settings, repo):
    style = flags.get('style', None)
    template = flags.get('template', 'medium')
    limit = flags.get('limit', 10)
    show_patch = flags.has_key('patch')
    follow = flags.has_key('follow-renames')
    first = flags.get('revision-start', None)
    last = flags.get('revision-end', args and args.pop(0) or 'HEAD')
    if flags.has_key('all'):
        limit = -1

    if flags.has_key('style') and flags.has_key('template'):
        raise HelpError(cmd, _('"style" and "template" are redundant.'))

    if flags.has_key('limit') and flags.has_key('all'):
        raise HelpError(cmd, _('"limit" and "all" conflict.'))

    # massage start position to make git show it to us, not valid for
    # reflog queries
    if first and first[-1] != '}':
        first += '^'

    color = 'color' in flags or \
            pyrite.utils.io.affirmative(settings.get_option('pyrite.color'))
    data, template = get_template(style, template, color)

    if not show_patch and Commit.PATCH in data:
        data.remove(Commit.PATCH)
    output = Commit.get_raw_commits(repo, first, last, limit=limit,
                                    data=data, follow=follow, paths=args)

    stream = io.info_stream()
    for commit_data in output:
        show_commit(commit_data, template, stream, repo)
Exemple #2
0
    def testLog(self):
        fn_name = self.whoami()

        self.createAndAdd(fn_name)
        self.repo.commit({Commit.SUBJECT: "test"})
        count = 0
        for commit in Commit.get_commits(self.repo, None, None):
            count += 1
        self.assertEqual(count, 1)
Exemple #3
0
def print_branch_stats(repo, branch, others):
    hist = repo[:branch]
    count = 0
    authors = {}
    for commit in hist:
        count += 1
        if commit.author_name in authors:
            authors[commit.author_name][0] += 1
        else:
            authors[commit.author_name] = [1, commit.author]

    print 'Number of commits in %s: %d' % (branch, count)
    print 'Total number of authors is: %d' % len(authors)
    print 'They are...'
    num_sorted = {}
    for name, info in authors.iteritems():
        num = info[0]
        if num in num_sorted:
            num_sorted[num].append(info[1])
        else:
            num_sorted[num] = [info[1]]

    for n in sorted(num_sorted.iterkeys()):
        for a in sorted(num_sorted[n]):
            print a + ': ' + str(n)
    print ''

    def show_changes(t1, t2):
        hist = repo[t1:t2]
        count = 0
        for commit in hist:
            count += 1
        if count > 0:
            print 'Number of commits since %s: %d' % \
                        (t1 and t1 or 'the beginning', count)
            tot_added = tot_lost = files = 0
            for added, lost, name in repo.num_stat(t1, t2):
                tot_added += added
                tot_lost += lost
                files += 1
            print '%d files changed, %d insertions(+), %d deletions(-)' % \
                    (files, tot_added, tot_lost)
            return True
        return False

    print branch
    tag, dummy, dummy = Commit.describe_commit(repo, branch)
    if not show_changes(tag, branch):
        tag, dummy, dummy = repo.describe(branch + '^')
        show_changes(tag, branch)

    for b in others:
        show_changes(b, branch)
Exemple #4
0
    def testCommitCommit(self):
        fn_name = self.whoami()

        self.doSimpleCommit(fn_name)
        c = Commit.get_raw_commits(
            self.repo, None, "HEAD", 1, [Commit.SUBJECT, Commit.ID, Commit.AUTHOR, Commit.AUTHOR_DATE]
        ).next()
        self.assertTrue(c)
        auth = c[Commit.AUTHOR]
        del c[Commit.AUTHOR]
        auth_date = c[Commit.AUTHOR_DATE]
        del c[Commit.AUTHOR_DATE]
        subj = c[Commit.SUBJECT]
        c[Commit.SUBJECT] = "should not be used"

        self.createAndAdd(fn_name + "2")
        self.repo.commit(c)
        c2 = Commit.get_raw_commits(
            self.repo, None, "HEAD", 1, [Commit.SUBJECT, Commit.ID, Commit.AUTHOR, Commit.AUTHOR_DATE]
        ).next()
        self.assertEqual(auth, c2[Commit.AUTHOR])
        self.assertEqual(auth_date, c2[Commit.AUTHOR_DATE])
        self.assertEqual(subj, c2[Commit.SUBJECT])
        self.assertNotEqual(c[Commit.ID], c2[Commit.ID])
Exemple #5
0
def run(cmd, args, flags, io, settings, repo):
    style = flags.get('style', None)
    template = flags.get('template', None)
    commit = None
    tag = None

    if style and template:
        raise HelpError(cmd, _('"style" and "template" are conflicting '
                               'arguments.'))

    if not args:
        raise HelpError(cmd, _('Need something to show'))
    if args[0] in repo.list_tags():
        tag = args.pop(0)
    elif Commit.is_commit(repo, args[0]):
        commit = args.pop(0)
    else:
        commit = 'HEAD'

    output = repo.show(commit=commit, tag=tag, files=args)

    io.info(output)