~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

- update annotate for new branch api
- show date for annotations that don't have a revno

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import sys
20
20
import os
 
21
import time
21
22
 
22
23
import bzrlib.weave
23
24
 
25
26
    if to_file is None:
26
27
        to_file = sys.stdout
27
28
    rh = branch.revision_history()
28
 
    w = branch.weave_store.get_weave(file_id)
 
29
    w = branch.weave_store.get_weave(file_id, branch.get_transaction())
29
30
    last_origin = None
30
31
    for origin, text in w.annotate_iter(rev_id):
31
32
        text = text.rstrip('\r\n')
32
33
        if origin == last_origin:
33
 
            print '      | %s' % (text)
 
34
            print '         | %s' % (text)
34
35
        else:
35
36
            last_origin = origin
36
37
            line_rev_id = w.idx_to_name(origin)
37
 
            try:
 
38
            if line_rev_id in rh:
38
39
                revno = rh.index(line_rev_id) + 1
39
 
                print '%5d | %s' % (revno, text)
40
 
            except ValueError:
41
 
                print 'merge | %s' % (text)
 
40
                print '%8d | %s' % (revno, text)
 
41
            elif branch.has_revision(line_rev_id):
 
42
                rev = branch.get_revision(line_rev_id)
 
43
                date_str = time.strftime('%Y%m%d', time.gmtime(rev.timestamp + rev.timezone))
 
44
                print '%8s | %s' % (date_str, text)
 
45
            else:
 
46
                print '%8.8s | %s' % (line_rev_id, text)
42
47
 
43
48
 
44
49
 
45
50
if __name__ == '__main__':
46
 
    from bzrlib.branch import find_branch
 
51
    from bzrlib.branch import Branch
47
52
    from bzrlib.trace import enable_default_logging
48
53
 
49
54
    enable_default_logging()
50
 
    b = find_branch(sys.argv[1])
 
55
    b = Branch.open_containing(sys.argv[1])
51
56
    rp = b.relpath(sys.argv[1])
52
57
    tree = b.revision_tree(b.last_revision())
53
58
    file_id = tree.inventory.path2id(rp)