##// END OF EJS Templates
subsetmaker: rework the antichain generation to be usable...
marmoute -
r49879:3f6ddb1c default
parent child Browse files
Show More
@@ -159,16 +159,44 b' def antichain(repo, subset, x):'
159 else:
159 else:
160 assert False
160 assert False
161
161
162 selected = set()
162 cl = repo.changelog
163
163
164 baseset = revset.getset(repo, smartset.fullreposet(repo), x)
164 # We already have cheap access to the parent mapping.
165 undecided = baseset
165 # However, we need to build a mapping of the children mapping
166 parents = repo.changelog._uncheckedparentrevs
167 children_map = collections.defaultdict(list)
168 for r in cl:
169 p1, p2 = parents(r)
170 if p1 >= 0:
171 children_map[p1].append(r)
172 if p2 >= 0:
173 children_map[p2].append(r)
174 children = children_map.__getitem__
175
176 selected = set()
177 undecided = SortedSet(cl)
166
178
167 while undecided:
179 while undecided:
168 pick = rand.choice(list(undecided))
180 # while there is "undecided content", we pick a random changeset X
181 # and we remove anything in `::X + X::` from undecided content
182 pick = rand.choice(undecided)
169 selected.add(pick)
183 selected.add(pick)
170 undecided = repo.revs(
184 undecided.remove(pick)
171 '%ld and not (::%ld or %ld::head())', baseset, selected, selected
185
172 )
186 ancestors = set(p for p in parents(pick) if p in undecided)
187 descendants = set(c for c in children(pick) if c in undecided)
188
189 while ancestors:
190 current = ancestors.pop()
191 undecided.remove(current)
192 for p in parents(current):
193 if p in undecided:
194 ancestors.add(p)
195 while descendants:
196 current = descendants.pop()
197 undecided.remove(current)
198 for p in children(current):
199 if p in undecided:
200 ancestors.add(p)
173
201
174 return smartset.baseset(selected) & subset
202 return smartset.baseset(selected) & subset
General Comments 0
You need to be logged in to leave comments. Login now