1
from bzrlib.branch import Branch
2
from bzrlib.config import extract_email_address
3
from bzrtools import short_committer
4
def branch_history(branch):
5
"""Print history of a branch"""
6
b = Branch.open_containing(branch)[0]
9
for revno, revision in iter_revisiondata(b):
10
new_descriptor = (revision.committer,
11
revision.properties.get('branch-nick'))
12
if descriptor is None:
13
descriptor = new_descriptor
16
if branch_change(descriptor, new_descriptor):
17
print_info(descriptor, start, revno - 1)
19
descriptor = new_descriptor
21
def branch_change(old_descriptor, new_descriptor):
22
if old_descriptor == new_descriptor:
24
elif None not in (old_descriptor[1], new_descriptor[1]) and \
25
old_descriptor[1] != new_descriptor[1]:
27
elif short_committer(old_descriptor[0]) ==\
28
short_committer(new_descriptor[0]):
30
elif old_descriptor[0].strip(' ') == \
31
extract_email_address(new_descriptor[0]):
33
elif new_descriptor[0].strip(' ') == \
34
extract_email_address(old_descriptor[0]):
39
def iter_revisiondata(branch):
40
"""Iterate through revno, Revision pairs in the revision history"""
41
for no, revision_id in enumerate(branch.revision_history()):
42
yield no+1, branch.get_revision(revision_id)
44
def print_info(descriptor, start, end):
45
"""Print revision history"""
46
descriptor_string = descriptor[0]
47
if descriptor[1] is not None:
48
descriptor_string += " / "+ descriptor[1]
49
print descriptor_string
51
print " %d .. %d" % (start, end)