67
60
end_of_merge)) in enumerate(merge_sorted_revisions):
69
revision = revisions[index]
70
rev_index[revid] = index
72
color = reduce(lambda x, y: x+y, revno_sequence[0:-2], 0)
74
parents = [parent for parent in graph_parents[revid] \
62
revid_index[revid] = index
63
revno_index[revno_sequence] = index
65
branch_id = revno_sequence[0:-1]
68
if branch_id not in branch_lines:
70
branch_lines[branch_id] = branch_line
71
branch_line["rev_indexes"] = []
72
branch_line["min_index"] = index - 1
73
branch_line["max_index"] = 0
75
branch_line = branch_lines[branch_id]
76
branch_line["rev_indexes"].append(index)
78
parents = graph_parents[revid]
77
79
for parent_revid in parents:
78
80
graph_children[parent_revid].append(revid)
80
children = graph_children[revid]
82
for child_revid in children:
83
child_index = rev_index[child_revid]
84
child_merge_depth = merge_sorted_revisions[child_index][2]
85
#out from the child to line
86
linegraph[child_index][2].append(
87
(child_merge_depth, #the column of the child
88
merge_depth, #the column of the line
91
for line_part_index in range(child_index+1, index):
92
linegraph[line_part_index][2].append(
93
(merge_depth, #the column of the child
94
merge_depth, #the column of the line
97
linegraph.append((revision,
82
linegraph.append([revid,
104
return (linegraph, rev_index, revisions)
89
branch_ids = branch_lines.keys()
93
for branch_id in branch_ids:
94
branch_line = branch_lines[branch_id]
95
branch_line["inward_line_ends"] = []
96
for rev_index in branch_line["rev_indexes"]:
101
end_of_merge) = merge_sorted_revisions[rev_index]
102
for parent_revid in graph_parents[revid]:
103
if parent_revid in revid_index:
104
parent_index = revid_index[parent_revid]
105
parent_merge_depth = merge_sorted_revisions[parent_index][2]
106
if parent_merge_depth < merge_depth:
107
branch_line["inward_line_ends"].append(parent_index)
108
if branch_line["max_index"] < parent_index:
109
branch_line["max_index"] =parent_index
111
for child_revid in graph_children[revid]:
112
if child_revid in revid_index:
113
child_index = revid_index[child_revid]
114
child_merge_depth = merge_sorted_revisions[child_index][2]
115
if child_merge_depth < merge_depth:
116
branch_line["inward_line_ends"].append(child_index)
121
start_col_index = branch_lines[branch_id[0:-2]]["col_index"]+1
122
for col_search_index in range(start_col_index,len(columns)):
123
column = columns[col_search_index]
126
if (line["min_index"] <= branch_line["min_index"] and \
127
line["max_index"] > branch_line["min_index"]) or \
128
(line["max_index"] >= branch_line["max_index"] and \
129
line["min_index"] < branch_line["max_index"]):
130
clashing_lines.append(line)
132
if not clashing_lines:
133
col_index = col_search_index
137
col_index = len(columns)
140
columns[col_index].append(branch_line)
141
branch_line["col_index"] = col_index
144
for branch_id in branch_ids:
145
branch_line = branch_lines[branch_id]
146
color = reduce(lambda x, y: x+y, branch_id, 0)
147
col_index = branch_line["col_index"]
148
node = (col_index, color)
150
for rev_index in branch_line["rev_indexes"]:
155
end_of_merge) = merge_sorted_revisions[rev_index]
156
children = graph_children[revid]
158
linegraph[rev_index][1] = node
159
linegraph[rev_index][4] = children
160
for child_revid in children:
161
if child_revid in revid_index:
162
child_index = revid_index[child_revid]
163
child_revno_sequence = \
164
merge_sorted_revisions[child_index][3]
165
child_merge_depth = merge_sorted_revisions[child_index][2]
166
child_branch_id = child_revno_sequence[0:-1]
167
child_col_index = branch_lines[child_branch_id]["col_index"]
168
if child_merge_depth < merge_depth:
169
#out from the child to line
170
linegraph[child_index][2].append(
174
for line_part_index in range(child_index+1, rev_index):
175
linegraph[line_part_index][2].append(
180
for line_part_index in range(child_index, rev_index-1):
181
linegraph[line_part_index][2].append(
186
linegraph[rev_index-1][2].append(
191
return (linegraph, revid_index)
107
194
def same_branch(a, b):