# HG changeset patch # User Pierre-Yves David # Date 2017-06-26 23:40:34 # Node ID 7017567ebdf2dd96b1a8ee6c0da61bd2d2210302 # Parent 0a370b93cca2b993654d32e3ddcbc477ec33f713 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. diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -19,7 +19,7 @@ from . import ( encoding, error, lock as lockmod, - obsolete, + obsutil, pycompat, scmutil, txnutil, @@ -682,7 +682,7 @@ def validdest(repo, old, new): # (new != nullrev has been excluded by the previous check) return True elif repo.obsstore: - return new.node() in obsolete.foreground(repo, [old.node()]) + return new.node() in obsutil.foreground(repo, [old.node()]) else: # still an independent clause as it is lazier (and therefore faster) return old.descendant(new) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -28,7 +28,7 @@ from . import ( error, filemerge, match as matchmod, - obsolete, + obsutil, pycompat, scmutil, subrepo, @@ -1588,8 +1588,8 @@ def update(repo, node, branchmerge, forc dirty = wc.dirty(missing=True) if dirty: # Branching is a bit strange to ensure we do the minimal - # amount of call to obsolete.foreground. - foreground = obsolete.foreground(repo, [p1.node()]) + # amount of call to obsutil.foreground. + foreground = obsutil.foreground(repo, [p1.node()]) # note: the variable contains a random identifier if repo[node].node() in foreground: pass # allow updating to successors diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -869,32 +869,6 @@ def successormarkers(ctx): for data in ctx.repo().obsstore.successors.get(ctx.node(), ()): yield marker(ctx.repo(), data) -def foreground(repo, nodes): - """return all nodes in the "foreground" of other node - - The foreground of a revision is anything reachable using parent -> children - or precursor -> successor relation. It is very similar to "descendant" but - augmented with obsolescence information. - - Beware that possible obsolescence cycle may result if complex situation. - """ - repo = repo.unfiltered() - foreground = set(repo.set('%ln::', nodes)) - if repo.obsstore: - # We only need this complicated logic if there is obsolescence - # XXX will probably deserve an optimised revset. - nm = repo.changelog.nodemap - plen = -1 - # compute the whole set of successors or descendants - while len(foreground) != plen: - plen = len(foreground) - succs = set(c.node() for c in foreground) - mutable = [c.node() for c in foreground if c.mutable()] - succs.update(obsutil.allsuccessors(repo.obsstore, mutable)) - known = (n for n in succs if n in nm) - foreground = set(repo.set('%ln::', known)) - return set(c.node() for c in foreground) - # keep compatibility for the 4.3 cycle def allprecursors(obsstore, nodes, ignoreflags=0): movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors' @@ -911,6 +885,11 @@ def exclusivemarkers(repo, nodes): repo.ui.deprecwarn(movemsg, '4.3') return obsutil.exclusivemarkers(repo, nodes) +def foreground(repo, nodes): + movemsg = 'obsolete.foreground moved to obsutil.foreground' + repo.ui.deprecwarn(movemsg, '4.3') + return obsutil.foreground(repo, nodes) + def successorssets(repo, initialnode, cache=None): movemsg = 'obsolete.successorssets moved to obsutil.successorssets' repo.ui.deprecwarn(movemsg, '4.3') diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py --- a/mercurial/obsutil.py +++ b/mercurial/obsutil.py @@ -203,6 +203,32 @@ def exclusivemarkers(repo, nodes): return exclmarkers +def foreground(repo, nodes): + """return all nodes in the "foreground" of other node + + The foreground of a revision is anything reachable using parent -> children + or precursor -> successor relation. It is very similar to "descendant" but + augmented with obsolescence information. + + Beware that possible obsolescence cycle may result if complex situation. + """ + repo = repo.unfiltered() + foreground = set(repo.set('%ln::', nodes)) + if repo.obsstore: + # We only need this complicated logic if there is obsolescence + # XXX will probably deserve an optimised revset. + nm = repo.changelog.nodemap + plen = -1 + # compute the whole set of successors or descendants + while len(foreground) != plen: + plen = len(foreground) + succs = set(c.node() for c in foreground) + mutable = [c.node() for c in foreground if c.mutable()] + succs.update(allsuccessors(repo.obsstore, mutable)) + known = (n for n in succs if n in nm) + foreground = set(repo.set('%ln::', known)) + return set(c.node() for c in foreground) + def successorssets(repo, initialnode, cache=None): """Return set of all latest successors of initial nodes