Show More
@@ -87,46 +87,46 b' def graph(repo, start_rev, stop_rev):' | |||||
87 |
|
87 | |||
88 | assert start_rev >= stop_rev |
|
88 | assert start_rev >= stop_rev | |
89 | assert stop_rev >= 0 |
|
89 | assert stop_rev >= 0 | |
90 |
cur |
|
90 | cur = start_rev | |
91 |
|
|
91 | seen = [] | |
92 | cl = repo.changelog |
|
92 | cl = repo.changelog | |
93 | colors = {} |
|
93 | colors = {} | |
94 |
new |
|
94 | newcolor = 1 | |
95 |
|
95 | |||
96 |
while cur |
|
96 | while cur >= stop_rev: | |
97 |
# Compute |
|
97 | # Compute seen and next | |
98 |
if cur |
|
98 | if cur not in seen: | |
99 |
|
|
99 | seen.append(cur) # new head | |
100 |
colors[cur |
|
100 | colors[cur] = newcolor | |
101 |
new |
|
101 | newcolor += 1 | |
102 |
|
102 | |||
103 |
|
|
103 | col = seen.index(cur) | |
104 |
color = colors.pop(cur |
|
104 | color = colors.pop(cur) | |
105 |
next = |
|
105 | next = seen[:] | |
106 |
|
106 | |||
107 | # Add parents to next_revs |
|
107 | # Add parents to next_revs | |
108 |
parents = [x for x in cl.parentrevs(cur |
|
108 | parents = [x for x in cl.parentrevs(cur) if x != nullrev] | |
109 | addparents = [p for p in parents if p not in next] |
|
109 | addparents = [p for p in parents if p not in next] | |
110 |
next[ |
|
110 | next[col:col + 1] = addparents | |
111 |
|
111 | |||
112 | # Set colors for the parents |
|
112 | # Set colors for the parents | |
113 | for i, p in enumerate(addparents): |
|
113 | for i, p in enumerate(addparents): | |
114 | if not i: |
|
114 | if not i: | |
115 | colors[p] = color |
|
115 | colors[p] = color | |
116 | else: |
|
116 | else: | |
117 |
colors[p] = new |
|
117 | colors[p] = newcolor | |
118 |
new |
|
118 | newcolor += 1 | |
119 |
|
119 | |||
120 | # Add edges to the graph |
|
120 | # Add edges to the graph | |
121 | edges = [] |
|
121 | edges = [] | |
122 |
for col, |
|
122 | for ecol, eid in enumerate(seen): | |
123 |
if |
|
123 | if eid in next: | |
124 |
edges.append((col, next.index( |
|
124 | edges.append((ecol, next.index(eid), colors[eid])) | |
125 |
elif |
|
125 | elif eid == id: | |
126 | for p in parents: |
|
126 | for p in parents: | |
127 | edges.append((col, next.index(p), colors[p])) |
|
127 | edges.append((ecol, next.index(p), colors[p])) | |
128 |
|
128 | |||
129 | # Yield and move on |
|
129 | # Yield and move on | |
130 |
yield (repo[cur |
|
130 | yield (repo[cur], (col, color), edges) | |
131 |
|
|
131 | seen = next | |
132 |
cur |
|
132 | cur -= 1 |
General Comments 0
You need to be logged in to leave comments.
Login now