Beispiel #1
0
    def body(self):
        from bzrlib import log

        rev1 = rev2 = self.revno
        if rev1 == 0:
            rev1 = None
            rev2 = None

        # use 'replace' so that we don't abort if trying to write out
        # in e.g. the default C locale.

        # We must use StringIO.StringIO because we want a Unicode string that
        # we can pass to send_email and have that do the proper encoding.
        from StringIO import StringIO
        outf = StringIO()

        outf.write('At %s\n\n' % self.url())

        lf = log.log_formatter('long', show_ids=True, to_file=outf)

        if len(self.revision.parent_ids) <= 1:
            # This is not a merge, so we can special case the display of one
            # revision, and not have to encur the show_log overhead.
            lr = log.LogRevision(self.revision, self.revno, 0, None)
            lf.log_revision(lr)
        else:
            # let the show_log code figure out what revisions need to be
            # displayed, as this is a merge
            log.show_log(self.branch,
                         lf,
                         start_revision=rev1,
                         end_revision=rev2,
                         verbose=True)

        return outf.getvalue()
Beispiel #2
0
 def log_screenful():
     lf = log_formatter(formatter, to_file=LineConsumer(25))
     try:
         show_log(tree.branch, lf, direction='reverse')
     except LinesDone:
         pass
     else:
         raise Exception, "LinesDone not raised"
    def getRevisionMessage(self, revision_id, revno):
        """Return the log message for a revision.

        :param revision_id: The revision-id of the revision.
        :param revno: The revno of the revision in the branch.
        :return: The log message entered for this revision.
        """
        self.bzr_branch.lock_read()
        try:
            graph = self.bzr_branch.repository.get_graph()
            merged_revisions = self.getMergedRevisionIDs(revision_id, graph)
            authors = self.getAuthors(merged_revisions, graph)
            revision_set = RevisionSet()
            rev_authors = revision_set.acquireRevisionAuthors(authors)
            outf = StringIO()
            pretty_authors = []
            for rev_author in rev_authors.values():
                if rev_author.person is None:
                    displayname = rev_author.name
                else:
                    displayname = rev_author.person.unique_displayname
                pretty_authors.append('  %s' % displayname)

            if len(pretty_authors) > 0:
                outf.write('Merge authors:\n')
                pretty_authors.sort(key=lambda x: x.lower())
                outf.write('\n'.join(pretty_authors[:5]))
                if len(pretty_authors) > 5:
                    outf.write('...\n')
                outf.write('\n')
            bmps = self.findRelatedBMP(merged_revisions)
            if len(bmps) > 0:
                outf.write('Related merge proposals:\n')
            for bmp in bmps:
                outf.write('  %s\n' % canonical_url(bmp))
                proposer = bmp.registrant
                outf.write('  proposed by: %s\n' %
                           proposer.unique_displayname)
                for review in bmp.votes:
                    # If comment is None, this is a request for a review, not
                    # a completed review.
                    if review.comment is None:
                        continue
                    outf.write('  review: %s - %s\n' %
                        (review.comment.vote.title,
                         review.reviewer.unique_displayname))
            info = RevisionInfo(self.bzr_branch, revno, revision_id)
            lf = log_formatter('long', to_file=outf)
            show_log(self.bzr_branch,
                     lf,
                     start_revision=info,
                     end_revision=info,
                     verbose=True)
        finally:
            self.bzr_branch.unlock()
        return outf.getvalue()
Beispiel #4
0
    def getRevisionMessage(self, revision_id, revno):
        """Return the log message for a revision.

        :param revision_id: The revision-id of the revision.
        :param revno: The revno of the revision in the branch.
        :return: The log message entered for this revision.
        """
        self.bzr_branch.lock_read()
        try:
            graph = self.bzr_branch.repository.get_graph()
            merged_revisions = self.getMergedRevisionIDs(revision_id, graph)
            authors = self.getAuthors(merged_revisions, graph)
            revision_set = RevisionSet()
            rev_authors = revision_set.acquireRevisionAuthors(authors)
            outf = StringIO()
            pretty_authors = []
            for rev_author in rev_authors.values():
                if rev_author.person is None:
                    displayname = rev_author.name
                else:
                    displayname = rev_author.person.unique_displayname
                pretty_authors.append('  %s' % displayname)

            if len(pretty_authors) > 0:
                outf.write('Merge authors:\n')
                pretty_authors.sort(key=lambda x: x.lower())
                outf.write('\n'.join(pretty_authors[:5]))
                if len(pretty_authors) > 5:
                    outf.write('...\n')
                outf.write('\n')
            bmps = self.findRelatedBMP(merged_revisions)
            if len(bmps) > 0:
                outf.write('Related merge proposals:\n')
            for bmp in bmps:
                outf.write('  %s\n' % canonical_url(bmp))
                proposer = bmp.registrant
                outf.write('  proposed by: %s\n' %
                           proposer.unique_displayname)
                for review in bmp.votes:
                    # If comment is None, this is a request for a review, not
                    # a completed review.
                    if review.comment is None:
                        continue
                    outf.write('  review: %s - %s\n' %
                        (review.comment.vote.title,
                         review.reviewer.unique_displayname))
            info = RevisionInfo(self.bzr_branch, revno, revision_id)
            lf = log_formatter('long', to_file=outf)
            show_log(self.bzr_branch,
                     lf,
                     start_revision=info,
                     end_revision=info,
                     verbose=True)
        finally:
            self.bzr_branch.unlock()
        return outf.getvalue()
Beispiel #5
0
    def body(self):
        from bzrlib import log

        rev1 = rev2 = self.revno
        if rev1 == 0:
            rev1 = None
            rev2 = None

        # use 'replace' so that we don't abort if trying to write out
        # in e.g. the default C locale.

        # We must use StringIO.StringIO because we want a Unicode string that
        # we can pass to send_email and have that do the proper encoding.
        from StringIO import StringIO
        outf = StringIO()

        outf.write('At %s\n\n' % self.url())

        lf = log.log_formatter('long',
                               show_ids=True,
                               to_file=outf
                               )

        if len(self.revision.parent_ids) <= 1:
            # This is not a merge, so we can special case the display of one
            # revision, and not have to encur the show_log overhead.
            lr = log.LogRevision(self.revision, self.revno, 0, None)
            lf.log_revision(lr)
        else:
            # let the show_log code figure out what revisions need to be
            # displayed, as this is a merge
            log.show_log(self.branch,
                         lf,
                         start_revision=rev1,
                         end_revision=rev2,
                         verbose=True
                         )

        return outf.getvalue()
Beispiel #6
0
    def run(self, num=10):
        try:
            num = int(num)
        except (ValueError, TypeError):
            num = 10
            warning('bzr lastlog only accepts numbers, defaulting to %d.' % num)

        dir, relpath = bzrdir.BzrDir.open_containing('.')
        b = dir.open_branch()

        num_revisions = len(b.revision_history())

        if num_revisions == 0:
            error('Sorry, no revisions available.')
            return

        first_revision = num_revisions - num + 1
        last_revision = num_revisions

        if first_revision < 1:
            first_revision = 1

        outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout,
                errors='replace')

        lf = log_formatter('short',
                           show_ids=False,
                           to_file=outf,
                           show_timezone='original')

        show_log(b,
                 lf,
                 None,
                 verbose=False,
                 direction='forward',
                 start_revision=first_revision,
                 end_revision=last_revision,
                 search=None)
Beispiel #7
0
 def test_merge_log(self):
     """Run log in a tree with many merges"""
     tree = self.make_heavily_merged_tree(hardlink=True)
     lf = log_formatter('short', to_file=StringIO())
     self.time(show_log, tree.branch, lf, direction='reverse')
Beispiel #8
0
 def test_log(self):
     """Run log in a many-commit tree."""
     tree = self.make_many_commit_tree(hardlink=True)
     lf = log_formatter('long', to_file=StringIO())
     self.time(show_log, tree.branch, lf, direction='reverse')
Beispiel #9
0
 def test_log_verbose(self):
     """'verbose' log -- shows file changes"""
     tree = self.make_many_commit_tree(hardlink=True)
     lf = log_formatter('long', to_file=StringIO())
     self.time(show_log, tree.branch, lf, direction='reverse', verbose=True)