Mercurial > hg
changeset 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 | 07439e9f245b |
files | mercurial/bookmarks.py mercurial/merge.py mercurial/obsolete.py mercurial/obsutil.py |
diffstat | 4 files changed, 36 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Tue Jun 27 01:36:20 2017 +0200 +++ b/mercurial/bookmarks.py Tue Jun 27 01:40:34 2017 +0200 @@ -19,7 +19,7 @@ encoding, error, lock as lockmod, - obsolete, + obsutil, pycompat, scmutil, txnutil, @@ -682,7 +682,7 @@ # (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)
--- a/mercurial/merge.py Tue Jun 27 01:36:20 2017 +0200 +++ b/mercurial/merge.py Tue Jun 27 01:40:34 2017 +0200 @@ -28,7 +28,7 @@ error, filemerge, match as matchmod, - obsolete, + obsutil, pycompat, scmutil, subrepo, @@ -1588,8 +1588,8 @@ 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 <node> variable contains a random identifier if repo[node].node() in foreground: pass # allow updating to successors
--- a/mercurial/obsolete.py Tue Jun 27 01:36:20 2017 +0200 +++ b/mercurial/obsolete.py Tue Jun 27 01:40:34 2017 +0200 @@ -869,32 +869,6 @@ 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 @@ 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')
--- a/mercurial/obsutil.py Tue Jun 27 01:36:20 2017 +0200 +++ b/mercurial/obsutil.py Tue Jun 27 01:40:34 2017 +0200 @@ -203,6 +203,32 @@ 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