Show More
@@ -20,6 +20,8 b' Data depends on type.' | |||||
20 | from mercurial.node import nullrev |
|
20 | from mercurial.node import nullrev | |
21 | import util |
|
21 | import util | |
22 |
|
22 | |||
|
23 | import heapq | |||
|
24 | ||||
23 | CHANGESET = 'C' |
|
25 | CHANGESET = 'C' | |
24 |
|
26 | |||
25 | def groupbranchiter(revs, parentsfunc): |
|
27 | def groupbranchiter(revs, parentsfunc): | |
@@ -40,8 +42,6 b' def groupbranchiter(revs, parentsfunc):' | |||||
40 | |/ |
|
42 | |/ | |
41 | o 0 |
|
43 | o 0 | |
42 |
|
44 | |||
43 | Currently does not handle non-contiguous <revs> input. |
|
|||
44 |
|
||||
45 | Currently consider every changeset under a merge to be on the same branch |
|
45 | Currently consider every changeset under a merge to be on the same branch | |
46 | using revision number to sort them. |
|
46 | using revision number to sort them. | |
47 |
|
47 | |||
@@ -103,16 +103,27 b' def groupbranchiter(revs, parentsfunc):' | |||||
103 | # |
|
103 | # | |
104 | # You could pre-seed the <parents> set of groups[0] to a specific |
|
104 | # You could pre-seed the <parents> set of groups[0] to a specific | |
105 | # changesets to select what the first emitted branch should be. |
|
105 | # changesets to select what the first emitted branch should be. | |
106 | # |
|
|||
107 | # We do not support revisions will hole yet, but adding such support would |
|
|||
108 | # be easy. The iteration will have to be done using both input revision and |
|
|||
109 | # parents (see cl.ancestors function + a few tweaks) but only revisions |
|
|||
110 | # parts of the initial set should be emitted. |
|
|||
111 | groups = [([], unblocked)] |
|
106 | groups = [([], unblocked)] | |
112 | for current in revs: |
|
107 | pendingheap = [] | |
113 | if True: |
|
108 | pendingset = set() | |
|
109 | ||||
|
110 | heapq.heapify(pendingheap) | |||
|
111 | heappop = heapq.heappop | |||
|
112 | heappush = heapq.heappush | |||
|
113 | for currentrev in revs: | |||
|
114 | # Heap works with smallest element, we want highest so we invert | |||
|
115 | if currentrev not in pendingset: | |||
|
116 | heappush(pendingheap, -currentrev) | |||
|
117 | pendingset.add(currentrev) | |||
|
118 | # iterates on pending rev until after the current rev have been | |||
|
119 | # processeed. | |||
|
120 | rev = None | |||
|
121 | while rev != currentrev: | |||
|
122 | rev = -heappop(pendingheap) | |||
|
123 | pendingset.remove(rev) | |||
|
124 | ||||
114 | # Seek for a subgroup blocked, waiting for the current revision. |
|
125 | # Seek for a subgroup blocked, waiting for the current revision. | |
115 |
matching = [i for i, g in enumerate(groups) if |
|
126 | matching = [i for i, g in enumerate(groups) if rev in g[1]] | |
116 |
|
127 | |||
117 | if matching: |
|
128 | if matching: | |
118 | # The main idea is to gather together all sets that await on |
|
129 | # The main idea is to gather together all sets that await on | |
@@ -140,7 +151,7 b' def groupbranchiter(revs, parentsfunc):' | |||||
140 | else: |
|
151 | else: | |
141 | # This is a new head. We create a new subgroup for it. |
|
152 | # This is a new head. We create a new subgroup for it. | |
142 | targetidx = len(groups) |
|
153 | targetidx = len(groups) | |
143 |
groups.append(([], set([ |
|
154 | groups.append(([], set([rev]))) | |
144 |
|
155 | |||
145 | gr = groups[targetidx] |
|
156 | gr = groups[targetidx] | |
146 |
|
157 | |||
@@ -150,9 +161,15 b' def groupbranchiter(revs, parentsfunc):' | |||||
150 | # |
|
161 | # | |
151 | # we also update the <parents> set to includes the parents on the |
|
162 | # we also update the <parents> set to includes the parents on the | |
152 | # new nodes. |
|
163 | # new nodes. | |
153 | gr[0].append(current) |
|
164 | if rev == currentrev: # only display stuff in rev | |
154 |
gr[ |
|
165 | gr[0].append(rev) | |
155 | gr[1].update([p for p in parentsfunc(current) if p > nullrev]) |
|
166 | gr[1].remove(rev) | |
|
167 | parents = [p for p in parentsfunc(rev) if p > nullrev] | |||
|
168 | gr[1].update(parents) | |||
|
169 | for p in parents: | |||
|
170 | if p not in pendingset: | |||
|
171 | pendingset.add(p) | |||
|
172 | heappush(pendingheap, -p) | |||
156 |
|
173 | |||
157 | # Look for a subgroup to display |
|
174 | # Look for a subgroup to display | |
158 | # |
|
175 | # | |
@@ -185,6 +202,11 b' def groupbranchiter(revs, parentsfunc):' | |||||
185 | del groups[targetidx] |
|
202 | del groups[targetidx] | |
186 | else: |
|
203 | else: | |
187 | gr[0][:] = [] |
|
204 | gr[0][:] = [] | |
|
205 | # Check if we have some subgroup waiting for revision we are not going to | |||
|
206 | # iterate over | |||
|
207 | for g in groups: | |||
|
208 | for r in g[0]: | |||
|
209 | yield r | |||
188 |
|
210 | |||
189 | def dagwalker(repo, revs): |
|
211 | def dagwalker(repo, revs): | |
190 | """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples |
|
212 | """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples |
@@ -37,6 +37,9 b' later.' | |||||
37 | |/ |
|
37 | |/ | |
38 | o 0 |
|
38 | o 0 | |
39 |
|
39 | |||
|
40 | ||||
|
41 | (display all nodes) | |||
|
42 | ||||
40 | $ hg --config experimental.graph-topological=1 log -G |
|
43 | $ hg --config experimental.graph-topological=1 log -G | |
41 | o 8 |
|
44 | o 8 | |
42 | | |
|
45 | | | |
@@ -56,3 +59,22 b' later.' | |||||
56 | |/ |
|
59 | |/ | |
57 | o 0 |
|
60 | o 0 | |
58 |
|
61 | |||
|
62 | ||||
|
63 | (revset skipping nodes) | |||
|
64 | ||||
|
65 | $ hg --config experimental.graph-topological=1 log -G --rev 'not (2+6)' | |||
|
66 | o 8 | |||
|
67 | | | |||
|
68 | o 3 | |||
|
69 | | | |||
|
70 | o 1 | |||
|
71 | | | |||
|
72 | | o 7 | |||
|
73 | | | | |||
|
74 | | o 5 | |||
|
75 | | | | |||
|
76 | | o 4 | |||
|
77 | |/ | |||
|
78 | o 0 | |||
|
79 | ||||
|
80 |
General Comments 0
You need to be logged in to leave comments.
Login now