changeset 33150:d0e5bf12f314

obsutil: move 'allprecursors' 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:31:18 +0200
parents d09ae850296d
children 0a370b93cca2
files mercurial/obsolete.py mercurial/obsutil.py
diffstat 2 files changed, 29 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Tue Jun 27 01:11:56 2017 +0200
+++ b/mercurial/obsolete.py	Tue Jun 27 01:31:18 2017 +0200
@@ -890,28 +890,6 @@
                     seen.add(suc)
                     remaining.add(suc)
 
-def allprecursors(obsstore, nodes, ignoreflags=0):
-    """Yield node for every precursors of <nodes>.
-
-    Some precursors may be unknown locally.
-
-    This is a linear yield unsuited to detecting folded changesets. It includes
-    initial nodes too."""
-
-    remaining = set(nodes)
-    seen = set(remaining)
-    while remaining:
-        current = remaining.pop()
-        yield current
-        for mark in obsstore.precursors.get(current, ()):
-            # ignore marker flagged with specified flag
-            if mark[2] & ignoreflags:
-                continue
-            suc = mark[0]
-            if suc not in seen:
-                seen.add(suc)
-                remaining.add(suc)
-
 def foreground(repo, nodes):
     """return all nodes in the "foreground" of other node
 
@@ -938,6 +916,12 @@
             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'
+    util.nouideprecwarn(movemsg, '4.3')
+    return obsutil.allprecursors(obsstore, nodes, ignoreflags)
+
 def exclusivemarkers(repo, nodes):
     movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers'
     repo.ui.deprecwarn(movemsg, '4.3')
@@ -1045,7 +1029,7 @@
         # We only evaluate mutable, non-obsolete revision
         node = ctx.node()
         # (future) A cache of precursors may worth if split is very common
-        for pnode in allprecursors(repo.obsstore, [node],
+        for pnode in obsutil.allprecursors(repo.obsstore, [node],
                                    ignoreflags=bumpedfix):
             prev = torev(pnode) # unfiltered! but so is phasecache
             if (prev is not None) and (phase(repo, prev) <= public):
--- a/mercurial/obsutil.py	Tue Jun 27 01:11:56 2017 +0200
+++ b/mercurial/obsutil.py	Tue Jun 27 01:31:18 2017 +0200
@@ -35,6 +35,28 @@
             else:
                 stack.append(precnodeid)
 
+def allprecursors(obsstore, nodes, ignoreflags=0):
+    """Yield node for every precursors of <nodes>.
+
+    Some precursors may be unknown locally.
+
+    This is a linear yield unsuited to detecting folded changesets. It includes
+    initial nodes too."""
+
+    remaining = set(nodes)
+    seen = set(remaining)
+    while remaining:
+        current = remaining.pop()
+        yield current
+        for mark in obsstore.precursors.get(current, ()):
+            # ignore marker flagged with specified flag
+            if mark[2] & ignoreflags:
+                continue
+            suc = mark[0]
+            if suc not in seen:
+                seen.add(suc)
+                remaining.add(suc)
+
 def _filterprunes(markers):
     """return a set with no prune markers"""
     return set(m for m in markers if m[1])