~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-02-18 02:33:47 UTC
  • mfrom: (1534.1.24 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060218023347-0952c65f668bfd68
Merge Robert Collins integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
# TODO: Show which revision caused a line to merge into the parent
24
24
 
25
 
# TODO: With --long, show entire email address, not just the first bit
26
 
 
27
25
# TODO: perhaps abbreviate timescales depending on how recent they are
28
26
# e.g. "3:12 Tue", "13 Oct", "Oct 2005", etc.  
29
27
 
42
40
        to_file = sys.stdout
43
41
 
44
42
    prevanno=''
45
 
    for (revno_str, author, date_str, line_rev_id, text ) in \
46
 
            _annotate_file(branch, rev_id, file_id ):
47
 
 
 
43
    annotation = list(_annotate_file(branch, rev_id, file_id))
 
44
    max_origin_len = max(len(origin) for origin in set(x[1] for x in annotation))
 
45
    for (revno_str, author, date_str, line_rev_id, text ) in annotation:
48
46
        if verbose:
49
 
            anno = '%5s %-12s %8s ' % (revno_str, author[:12], date_str)
 
47
            anno = '%5s %-*s %8s ' % (revno_str, max_origin_len, author, date_str)
50
48
        else:
51
49
            anno = "%5s %-7s " % ( revno_str, author[:7] )
52
50
 
57
55
def _annotate_file(branch, rev_id, file_id ):
58
56
 
59
57
    rh = branch.revision_history()
60
 
    w = branch.weave_store.get_weave(file_id, branch.get_transaction())
 
58
    w = branch.repository.weave_store.get_weave(file_id, 
 
59
        branch.repository.get_transaction())
61
60
    last_origin = None
62
61
    for origin, text in w.annotate_iter(rev_id):
63
62
        text = text.rstrip('\r\n')
66
65
        else:
67
66
            last_origin = origin
68
67
            line_rev_id = w.idx_to_name(origin)
69
 
            if not branch.has_revision(line_rev_id):
 
68
            if not branch.repository.has_revision(line_rev_id):
70
69
                (revno_str, author, date_str) = ('?','?','?')
71
70
            else:
72
71
                if line_rev_id in rh:
73
72
                    revno_str = str(rh.index(line_rev_id) + 1)
74
73
                else:
75
74
                    revno_str = 'merge'
76
 
            rev = branch.get_revision(line_rev_id)
 
75
            rev = branch.repository.get_revision(line_rev_id)
77
76
            tz = rev.timezone or 0
78
77
            date_str = time.strftime('%Y%m%d', 
79
78
                                     time.gmtime(rev.timestamp + tz))