Show More
@@ -110,79 +110,81 b' def groupbranchiter(revs, parentsfunc):' | |||||
110 | # parts of the initial set should be emitted. |
|
110 | # parts of the initial set should be emitted. | |
111 | groups = [([], unblocked)] |
|
111 | groups = [([], unblocked)] | |
112 | for current in revs: |
|
112 | for current in revs: | |
113 | # Look for a subgroup blocked, waiting for the current revision. |
|
113 | if True: | |
114 | matching = [i for i, g in enumerate(groups) if current in g[1]] |
|
114 | # Seek for a subgroup blocked, waiting for the current revision. | |
|
115 | matching = [i for i, g in enumerate(groups) if current in g[1]] | |||
115 |
|
116 | |||
116 | if matching: |
|
117 | if matching: | |
117 |
# The main idea is to gather together all sets that await on |
|
118 | # The main idea is to gather together all sets that await on | |
118 | # same revision. |
|
119 | # the same revision. | |
119 | # |
|
120 | # | |
120 |
# This merging is done at the time we are about to add this |
|
121 | # This merging is done at the time we are about to add this | |
121 |
# awaited to the subgroup for simplicity purpose. Such |
|
122 | # common awaited to the subgroup for simplicity purpose. Such | |
122 |
# happen sooner when we update the "blocked" set of |
|
123 | # merge could happen sooner when we update the "blocked" set of | |
123 | # |
|
124 | # revision. | |
124 | # We also always keep the oldest subgroup first. We can probably |
|
125 | # | |
125 | # improve the behavior by having the longuest set first. That way, |
|
126 | # We also always keep the oldest subgroup first. We can | |
126 | # graph algorythms could minimise the length of parallele lines |
|
127 | # probably improve the behavior by having the longuest set | |
127 | # their draw. This is currently not done. |
|
128 | # first. That way, graph algorythms could minimise the length | |
128 | targetidx = matching.pop(0) |
|
129 | # of parallele lines their draw. This is currently not done. | |
129 | trevs, tparents = groups[targetidx] |
|
130 | targetidx = matching.pop(0) | |
130 | for i in matching: |
|
131 | trevs, tparents = groups[targetidx] | |
131 |
|
|
132 | for i in matching: | |
132 | trevs.extend(gr[0]) |
|
133 | gr = groups[i] | |
133 |
|
|
134 | trevs.extend(gr[0]) | |
134 | # delete all merged subgroups (but the one we keep) |
|
135 | tparents |= gr[1] | |
135 | # (starting from the last subgroup for performance and sanity reason) |
|
136 | # delete all merged subgroups (but the one we keep) (starting | |
136 | for i in reversed(matching): |
|
137 | # from the last subgroup for performance and sanity reason) | |
137 | del groups[i] |
|
138 | for i in reversed(matching): | |
138 | else: |
|
139 | del groups[i] | |
139 | # This is a new head. We create a new subgroup for it. |
|
140 | else: | |
140 | targetidx = len(groups) |
|
141 | # This is a new head. We create a new subgroup for it. | |
141 | groups.append(([], set([current]))) |
|
142 | targetidx = len(groups) | |
|
143 | groups.append(([], set([current]))) | |||
142 |
|
144 | |||
143 | gr = groups[targetidx] |
|
145 | gr = groups[targetidx] | |
144 |
|
146 | |||
145 |
# We now adds the current nodes to this subgroups. This is done |
|
147 | # We now adds the current nodes to this subgroups. This is done | |
146 |
# the subgroup merging because all elements from a subgroup |
|
148 | # after the subgroup merging because all elements from a subgroup | |
147 | # on this rev must preceed it. |
|
149 | # that relied on this rev must preceed it. | |
148 | # |
|
150 | # | |
149 | # we also update the <parents> set to includes the parents on the |
|
151 | # we also update the <parents> set to includes the parents on the | |
150 | # new nodes. |
|
152 | # new nodes. | |
151 | gr[0].append(current) |
|
153 | gr[0].append(current) | |
152 | gr[1].remove(current) |
|
154 | gr[1].remove(current) | |
153 | gr[1].update([p for p in parentsfunc(current) if p > nullrev]) |
|
155 | gr[1].update([p for p in parentsfunc(current) if p > nullrev]) | |
154 |
|
156 | |||
155 | # Look for a subgroup to display |
|
157 | # Look for a subgroup to display | |
156 | # |
|
158 | # | |
157 | # When unblocked is empty (if clause), We are not waiting over any |
|
159 | # When unblocked is empty (if clause), We are not waiting over any | |
158 |
# revision during the first iteration (if no priority was given) or |
|
160 | # revision during the first iteration (if no priority was given) or | |
159 |
# we outputed a whole disconnected sets of the graph (reached a |
|
161 | # if we outputed a whole disconnected sets of the graph (reached a | |
160 |
# In that case we arbitrarily takes the oldest known |
|
162 | # root). In that case we arbitrarily takes the oldest known | |
161 | # heuristique could probably be better. |
|
163 | # subgroup. The heuristique could probably be better. | |
162 | # |
|
164 | # | |
163 |
# Otherwise (elif clause) this mean we have some emitted revision. |
|
165 | # Otherwise (elif clause) this mean we have some emitted revision. | |
164 |
# the subgroup awaits on the same revision that the outputed |
|
166 | # if the subgroup awaits on the same revision that the outputed | |
165 | # can safely output it. |
|
167 | # ones, we can safely output it. | |
166 | if not unblocked: |
|
168 | if not unblocked: | |
167 | if len(groups) > 1: # display other subset |
|
169 | if len(groups) > 1: # display other subset | |
168 | targetidx = 1 |
|
170 | targetidx = 1 | |
169 | gr = groups[1] |
|
171 | gr = groups[1] | |
170 | elif not gr[1] & unblocked: |
|
172 | elif not gr[1] & unblocked: | |
171 | gr = None |
|
173 | gr = None | |
172 |
|
174 | |||
173 | if gr is not None: |
|
175 | if gr is not None: | |
174 | # update the set of awaited revisions with the one from the |
|
176 | # update the set of awaited revisions with the one from the | |
175 | # subgroup |
|
177 | # subgroup | |
176 | unblocked |= gr[1] |
|
178 | unblocked |= gr[1] | |
177 | # output all revisions in the subgroup |
|
179 | # output all revisions in the subgroup | |
178 | for r in gr[0]: |
|
180 | for r in gr[0]: | |
179 | yield r |
|
181 | yield r | |
180 | # delete the subgroup that you just output |
|
182 | # delete the subgroup that you just output | |
181 | # unless it is groups[0] in which case you just empty it. |
|
183 | # unless it is groups[0] in which case you just empty it. | |
182 | if targetidx: |
|
184 | if targetidx: | |
183 | del groups[targetidx] |
|
185 | del groups[targetidx] | |
184 | else: |
|
186 | else: | |
185 | gr[0][:] = [] |
|
187 | gr[0][:] = [] | |
186 |
|
188 | |||
187 | def dagwalker(repo, revs): |
|
189 | def dagwalker(repo, revs): | |
188 | """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples |
|
190 | """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples |
General Comments 0
You need to be logged in to leave comments.
Login now