comparison mercurial/obsutil.py @ 33146:7017567ebdf2

obsutil: move 'foreground' to the new modules We have a new 'obsutil' module now. We move the high level utility there to bring 'obsolete.py' back to a more reasonable size.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 27 Jun 2017 01:40:34 +0200
parents 0a370b93cca2
children 4e30168d7939
comparison
equal deleted inserted replaced
33145:0a370b93cca2 33146:7017567ebdf2
200 if precmarkers.issubset(exclmarkers): 200 if precmarkers.issubset(exclmarkers):
201 seennodes.add(prec) 201 seennodes.add(prec)
202 stack.append(prec) 202 stack.append(prec)
203 203
204 return exclmarkers 204 return exclmarkers
205
206 def foreground(repo, nodes):
207 """return all nodes in the "foreground" of other node
208
209 The foreground of a revision is anything reachable using parent -> children
210 or precursor -> successor relation. It is very similar to "descendant" but
211 augmented with obsolescence information.
212
213 Beware that possible obsolescence cycle may result if complex situation.
214 """
215 repo = repo.unfiltered()
216 foreground = set(repo.set('%ln::', nodes))
217 if repo.obsstore:
218 # We only need this complicated logic if there is obsolescence
219 # XXX will probably deserve an optimised revset.
220 nm = repo.changelog.nodemap
221 plen = -1
222 # compute the whole set of successors or descendants
223 while len(foreground) != plen:
224 plen = len(foreground)
225 succs = set(c.node() for c in foreground)
226 mutable = [c.node() for c in foreground if c.mutable()]
227 succs.update(allsuccessors(repo.obsstore, mutable))
228 known = (n for n in succs if n in nm)
229 foreground = set(repo.set('%ln::', known))
230 return set(c.node() for c in foreground)
205 231
206 def successorssets(repo, initialnode, cache=None): 232 def successorssets(repo, initialnode, cache=None):
207 """Return set of all latest successors of initial nodes 233 """Return set of all latest successors of initial nodes
208 234
209 The successors set of a changeset A are the group of revisions that succeed 235 The successors set of a changeset A are the group of revisions that succeed