17
17
"""File annotate based on weave storage"""
19
# TODO: Choice of more or less verbose formats:
21
# short: just show revno
22
# long: revno, author, date
23
# interposed: show more details between blocks of modified lines
25
# TODO: Show which revision caused a line to merge into the parent
22
31
import bzrlib.weave
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())
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
print ' | %s' % (text)
35
44
last_origin = origin
36
45
line_rev_id = w.idx_to_name(origin)
38
47
revno = rh.index(line_rev_id) + 1
39
print '%5d | %s' % (revno, text)
41
print 'merge | %s' % (text)
48
print '%8d | %s' % (revno, text)
49
elif branch.has_revision(line_rev_id):
50
rev = branch.get_revision(line_rev_id)
51
date_str = time.strftime('%Y%m%d', time.gmtime(rev.timestamp + rev.timezone))
52
print '%8s | %s' % (date_str, text)
54
print '%8.8s | %s' % (line_rev_id, text)
45
58
if __name__ == '__main__':
46
from bzrlib.branch import find_branch
59
from bzrlib.branch import Branch
47
60
from bzrlib.trace import enable_default_logging
49
62
enable_default_logging()
50
b = find_branch(sys.argv[1])
63
b = Branch.open_containing(sys.argv[1])
51
64
rp = b.relpath(sys.argv[1])
52
65
tree = b.revision_tree(b.last_revision())
53
66
file_id = tree.inventory.path2id(rp)