[PATCH 3 of 8 V2] obsutil: move 'allprecursors' to the new modules

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jun 28 17:21:54 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1498519878 -7200
#      Tue Jun 27 01:31:18 2017 +0200
# Node ID 544a98d10bc3a3624e103e6aa3460e263767e258
# Parent  50b7ef430d3c7fae1d704b5ee847d54e5cec05a2
# EXP-Topic obsutil
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 544a98d10bc3
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.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -890,28 +890,6 @@ def allsuccessors(obsstore, nodes, ignor
                     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 @@ def foreground(repo, nodes):
             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')
@@ -1039,7 +1023,7 @@ def _computebumpedset(repo):
         # 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):
diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -35,6 +35,28 @@ def closestpredecessors(repo, nodeid):
             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])


More information about the Mercurial-devel mailing list