/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/annotate.py

  • Committer: abentley
  • Date: 2005-10-15 01:07:02 UTC
  • mfrom: (1185.16.40)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1460.
  • Revision ID: abentley@lappy-20051015010702-0b7a58668e447397
MergeĀ fromĀ Martin

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""File annotate based on weave storage"""
18
18
 
 
19
# TODO: Choice of more or less verbose formats:
 
20
 
21
# short: just show revno
 
22
# long: revno, author, date
 
23
# interposed: show more details between blocks of modified lines
 
24
 
 
25
# TODO: Show which revision caused a line to merge into the parent
 
26
 
19
27
import sys
20
28
import os
 
29
import time
21
30
 
22
31
import bzrlib.weave
23
32
 
25
34
    if to_file is None:
26
35
        to_file = sys.stdout
27
36
    rh = branch.revision_history()
28
 
    w = branch.weave_store.get_weave(file_id)
 
37
    w = branch.weave_store.get_weave(file_id, branch.get_transaction())
29
38
    last_origin = None
30
39
    for origin, text in w.annotate_iter(rev_id):
31
40
        text = text.rstrip('\r\n')
32
41
        if origin == last_origin:
33
 
            print '      | %s' % (text)
 
42
            anno = ''
34
43
        else:
35
44
            last_origin = origin
36
45
            line_rev_id = w.idx_to_name(origin)
37
 
            try:
38
 
                revno = rh.index(line_rev_id) + 1
39
 
                print '%5d | %s' % (revno, text)
40
 
            except ValueError:
41
 
                print 'merge | %s' % (text)
42
 
 
 
46
            if not branch.has_revision(line_rev_id):
 
47
                anno = '???'
 
48
            else:
 
49
                if line_rev_id in rh:
 
50
                    revno_str = str(rh.index(line_rev_id) + 1)
 
51
                else:
 
52
                    revno_str = 'merge'
 
53
            rev = branch.get_revision(line_rev_id)
 
54
            tz = rev.timezone or 0
 
55
            date_str = time.strftime('%Y%m%d', 
 
56
                                     time.gmtime(rev.timestamp + tz))
 
57
            # a lazy way to get something like the email address
 
58
            # TODO: Get real email address
 
59
            author = line_rev_id
 
60
            if '@' in author:
 
61
                author = author[:author.index('@')]
 
62
            author = author[:12]
 
63
            anno = '%5s %-12s %8s' % (revno_str, author, date_str)
 
64
        print '%-27.27s | %s' % (anno, text)
43
65
 
44
66
 
45
67
if __name__ == '__main__':
46
 
    from bzrlib.branch import find_branch
 
68
    from bzrlib.branch import Branch
47
69
    from bzrlib.trace import enable_default_logging
48
70
 
49
71
    enable_default_logging()
50
 
    b = find_branch(sys.argv[1])
 
72
    b = Branch.open_containing(sys.argv[1])
51
73
    rp = b.relpath(sys.argv[1])
52
74
    tree = b.revision_tree(b.last_revision())
53
75
    file_id = tree.inventory.path2id(rp)