24
24
if len(new_committer) < 2:
26
26
return new_committer
29
def graph_ancestry(branch):
29
def compact_descendants(descendants, ancestors):
32
for me, my_descendants in descendants.iteritems():
35
new_descendants[me] = []
36
for descendant in my_descendants:
37
new_descendant = descendant
38
while new_descendant in descendants and \
39
len(ancestors[new_descendant]) == 1 and \
40
len(descendants[new_descendant]) == 1:
41
skip.add(new_descendant)
42
if new_descendant in new_descendants:
43
del new_descendants[new_descendant]
44
new_descendant = descendants[new_descendant][0]
45
new_descendants[me].append(new_descendant)
46
return new_descendants
49
def graph_ancestry(branch, collapse=True):
31
51
q = ((i+1, n) for (i, n) in enumerate(branch.revision_history()))
60
80
descendants[parent].append(rev_id)
62
82
node_relations = []
63
def compact_descendants():
66
for me, my_descendants in descendants.iteritems():
69
new_descendants[me] = []
70
for descendant in my_descendants:
71
new_descendant = descendant
72
while new_descendant in descendants and \
73
len(ancestors[new_descendant]) == 1 and \
74
len(descendants[new_descendant]) == 1:
75
skip.add(new_descendant)
76
if new_descendant in new_descendants:
77
del new_descendants[new_descendant]
78
new_descendant = descendants[new_descendant][0]
79
new_descendants[me].append(new_descendant)
80
return new_descendants
85
visible_descendants = compact_descendants(descendants, ancestors)
87
visible_descendants = descendants
82
for key, values in compact_descendants().iteritems():
89
for key, values in visible_descendants.iteritems():
83
90
for value in values:
84
91
node_relations.append((nodes[key], nodes[value]))
85
92
return node_relations
87
def write_ancestry_file(branch, filename):
94
def write_ancestry_file(branch, filename, collapse=True):
89
relations = graph_ancestry(b)
96
relations = graph_ancestry(b, collapse)
90
97
ext = filename.split('.')[-1]
91
98
if ext in ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png'):
92
99
invoke_dot(dot_output(relations), filename, ext)