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
20
print_info(descriptor, start, revno)
22
def branch_change(old_descriptor, new_descriptor):
23
if old_descriptor == new_descriptor:
25
elif None not in (old_descriptor[1], new_descriptor[1]) and \
26
old_descriptor[1] != new_descriptor[1]:
28
elif short_committer(old_descriptor[0]) ==\
29
short_committer(new_descriptor[0]):
31
elif old_descriptor[0].strip(' ') == \
32
extract_email_address(new_descriptor[0]):
34
elif new_descriptor[0].strip(' ') == \
35
extract_email_address(old_descriptor[0]):
40
def iter_revisiondata(branch):
41
"""Iterate through revno, Revision pairs in the revision history"""
42
for no, revision_id in enumerate(branch.revision_history()):
43
yield no+1, branch.repository.get_revision(revision_id)
45
def print_info(descriptor, start, end):
46
"""Print revision history"""
47
descriptor_string = descriptor[0]
48
if descriptor[1] is not None:
49
descriptor_string += " / "+ descriptor[1]
50
print descriptor_string
52
print " %d .. %d" % (start, end)