Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/graphmod.py @ 8841:94ac080e7af9
graphmod: rename a bunch of vars in graph()
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Sat, 16 May 2009 07:12:12 +0200 |
parents | d9acbe7b0049 |
children | acd03a6e2426 |
comparison
equal
deleted
inserted
replaced
8840:d9acbe7b0049 | 8841:94ac080e7af9 |
---|---|
85 if start_rev == nullrev and not stop_rev: | 85 if start_rev == nullrev and not stop_rev: |
86 return | 86 return |
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 curr_rev = start_rev | 90 cur = start_rev |
91 revs = [] | 91 seen = [] |
92 cl = repo.changelog | 92 cl = repo.changelog |
93 colors = {} | 93 colors = {} |
94 new_color = 1 | 94 newcolor = 1 |
95 | 95 |
96 while curr_rev >= stop_rev: | 96 while cur >= stop_rev: |
97 # Compute revs and next_revs | 97 # Compute seen and next |
98 if curr_rev not in revs: | 98 if cur not in seen: |
99 revs.append(curr_rev) # new head | 99 seen.append(cur) # new head |
100 colors[curr_rev] = new_color | 100 colors[cur] = newcolor |
101 new_color += 1 | 101 newcolor += 1 |
102 | 102 |
103 idx = revs.index(curr_rev) | 103 col = seen.index(cur) |
104 color = colors.pop(curr_rev) | 104 color = colors.pop(cur) |
105 next = revs[:] | 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(curr_rev) if x != nullrev] | 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[idx:idx + 1] = addparents | 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_color | 117 colors[p] = newcolor |
118 new_color += 1 | 118 newcolor += 1 |
119 | 119 |
120 # Add edges to the graph | 120 # Add edges to the graph |
121 edges = [] | 121 edges = [] |
122 for col, r in enumerate(revs): | 122 for ecol, eid in enumerate(seen): |
123 if r in next: | 123 if eid in next: |
124 edges.append((col, next.index(r), colors[r])) | 124 edges.append((ecol, next.index(eid), colors[eid])) |
125 elif r == curr_rev: | 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[curr_rev], (idx, color), edges) | 130 yield (repo[cur], (col, color), edges) |
131 revs = next | 131 seen = next |
132 curr_rev -= 1 | 132 cur -= 1 |