/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
In verbose mode we show a summary of what changed in each particular
44
44
revision.  Note that this is the delta for changes in that revision
45
 
relative to its mainline parent, not the delta relative to the last
 
45
relative to its left-most parent, not the delta relative to the last
46
46
logged revision.  So for example if you ask for a verbose log of
47
47
changes touching hello.c you will get a list of those revisions also
48
48
listing other things that were changed in the same revision, but not
49
49
all the changes since the previous revision that touched hello.c.
50
50
"""
51
51
 
52
 
# TODO: option to show delta summaries for merged-in revisions
53
 
 
54
52
from itertools import izip
55
53
import re
56
54
 
64
62
    )
65
63
from bzrlib.symbol_versioning import (
66
64
    deprecated_method,
67
 
    zero_eleven,
68
65
    zero_seventeen,
69
66
    )
70
67
from bzrlib.trace import mutter
243
240
                                                         mainline_revs,
244
241
                                                         view_revisions)
245
242
 
 
243
    # rebase merge_depth - unless there are no revisions or 
 
244
    # either the first or last revision have merge_depth = 0.
 
245
    if view_revisions and view_revisions[0][2] and view_revisions[-1][2]:
 
246
        min_depth = min([d for r,n,d in view_revisions])
 
247
        if min_depth != 0:
 
248
            view_revisions = [(r,n,d-min_depth) for r,n,d in view_revisions]
 
249
        
246
250
    rev_tag_dict = {}
247
251
    generate_tags = getattr(lf, 'supports_tags', False)
248
252
    if generate_tags:
560
564
    - supports_delta must be True if this log formatter supports delta.
561
565
        Otherwise the delta attribute may not be populated.
562
566
    - supports_merge_revisions must be True if this log formatter supports 
563
 
        merge revisions.  If not, only revisions mainline revisions (those 
 
567
        merge revisions.  If not, only mainline revisions (those 
564
568
        with merge_depth == 0) will be passed to the formatter.
565
569
    - supports_tags must be True if this log formatter supports tags.
566
570
        Otherwise the tags attribute may not be populated.
588
592
    def short_committer(self, rev):
589
593
        return re.sub('<.*@.*>', '', rev.committer).strip(' ')
590
594
 
 
595
    def short_author(self, rev):
 
596
        return re.sub('<.*@.*>', '', rev.get_apparent_author()).strip(' ')
 
597
 
591
598
 
592
599
class LongLogFormatter(LogFormatter):
593
600
 
600
607
        lr = LogRevision(rev, revno, 0, delta, tags)
601
608
        return self.log_revision(lr)
602
609
 
603
 
    @deprecated_method(zero_eleven)
604
 
    def show_merge(self, rev, merge_depth):
605
 
        lr = LogRevision(rev, merge_depth=merge_depth)
606
 
        return self.log_revision(lr)
607
 
 
608
610
    @deprecated_method(zero_seventeen)
609
611
    def show_merge_revno(self, rev, merge_depth, revno, tags=None):
610
612
        """Show a merged revision rev, with merge_depth and a revno."""
614
616
    def log_revision(self, revision):
615
617
        """Log a revision, either merged or not."""
616
618
        from bzrlib.osutils import format_date
617
 
        indent = '    '*revision.merge_depth
 
619
        indent = '    ' * revision.merge_depth
618
620
        to_file = self.to_file
619
 
        print >>to_file,  indent+'-' * 60
 
621
        print >>to_file, indent + '-' * 60
620
622
        if revision.revno is not None:
621
 
            print >>to_file,  indent+'revno:', revision.revno
 
623
            print >>to_file, indent + 'revno:', revision.revno
622
624
        if revision.tags:
623
 
            print >>to_file, indent+'tags: %s' % (', '.join(revision.tags))
 
625
            print >>to_file, indent + 'tags: %s' % (', '.join(revision.tags))
624
626
        if self.show_ids:
625
 
            print >>to_file, indent+'revision-id:', revision.rev.revision_id
 
627
            print >>to_file, indent + 'revision-id:', revision.rev.revision_id
626
628
            for parent_id in revision.rev.parent_ids:
627
 
                print >>to_file, indent+'parent:', parent_id
628
 
        print >>to_file, indent+'committer:', revision.rev.committer
629
 
 
630
 
        try:
631
 
            print >>to_file, indent+'branch nick: %s' % \
632
 
                revision.rev.properties['branch-nick']
633
 
        except KeyError:
634
 
            pass
 
629
                print >>to_file, indent + 'parent:', parent_id
 
630
 
 
631
        author = revision.rev.properties.get('author', None)
 
632
        if author is not None:
 
633
            print >>to_file, indent + 'author:', author
 
634
        print >>to_file, indent + 'committer:', revision.rev.committer
 
635
 
 
636
        branch_nick = revision.rev.properties.get('branch-nick', None)
 
637
        if branch_nick is not None:
 
638
            print >>to_file, indent + 'branch nick:', branch_nick
 
639
 
635
640
        date_str = format_date(revision.rev.timestamp,
636
641
                               revision.rev.timezone or 0,
637
642
                               self.show_timezone)
638
 
        print >>to_file,  indent+'timestamp: %s' % date_str
 
643
        print >>to_file, indent + 'timestamp: %s' % date_str
639
644
 
640
 
        print >>to_file,  indent+'message:'
 
645
        print >>to_file, indent + 'message:'
641
646
        if not revision.rev.message:
642
 
            print >>to_file,  indent+'  (no message)'
 
647
            print >>to_file, indent + '  (no message)'
643
648
        else:
644
649
            message = revision.rev.message.rstrip('\r\n')
645
650
            for l in message.split('\n'):
646
 
                print >>to_file,  indent+'  ' + l
 
651
                print >>to_file, indent + '  ' + l
647
652
        if revision.delta is not None:
648
653
            revision.delta.show(to_file, self.show_ids, indent=indent)
649
654
 
668
673
        if len(revision.rev.parent_ids) > 1:
669
674
            is_merge = ' [merge]'
670
675
        print >>to_file, "%5s %s\t%s%s" % (revision.revno,
671
 
                self.short_committer(revision.rev),
 
676
                self.short_author(revision.rev),
672
677
                format_date(revision.rev.timestamp,
673
678
                            revision.rev.timezone or 0,
674
679
                            self.show_timezone, date_fmt="%Y-%m-%d",
735
740
        if revno:
736
741
            # show revno only when is not None
737
742
            out.append("%s:" % revno)
738
 
        out.append(self.truncate(self.short_committer(rev), 20))
 
743
        out.append(self.truncate(self.short_author(rev), 20))
739
744
        out.append(self.date_string(rev))
740
745
        out.append(rev.get_summary())
741
746
        return self.truncate(" ".join(out).rstrip('\n'), max_chars)
795
800
    lf.show(revno, rev, delta)
796
801
 
797
802
 
798
 
def show_changed_revisions(branch, old_rh, new_rh, to_file=None, log_format='long'):
 
803
def show_changed_revisions(branch, old_rh, new_rh, to_file=None,
 
804
                           log_format='long'):
799
805
    """Show the change in revision history comparing the old revision history to the new one.
800
806
 
801
807
    :param branch: The branch where the revisions exist
807
813
        import sys
808
814
        import codecs
809
815
        import bzrlib
810
 
        to_file = codecs.getwriter(bzrlib.user_encoding)(sys.stdout, errors='replace')
 
816
        to_file = codecs.getwriter(bzrlib.user_encoding)(sys.stdout,
 
817
                                                         errors='replace')
811
818
    lf = log_formatter(log_format,
812
819
                       show_ids=False,
813
820
                       to_file=to_file,
844
851
        show_log(branch,
845
852
                 lf,
846
853
                 None,
847
 
                 verbose=True,
 
854
                 verbose=False,
848
855
                 direction='forward',
849
856
                 start_revision=base_idx+1,
850
857
                 end_revision=len(new_rh),