[PATCH 4 of 8 V2] obsutil: move 'allsuccessors' to the new modules

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


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1498520180 -7200
#      Tue Jun 27 01:36:20 2017 +0200
# Node ID 939f252188eb3b3d7c496c457fe2e1332bdb5f32
# Parent  544a98d10bc3a3624e103e6aa3460e263767e258
# 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 939f252188eb
obsutil: move 'allsuccessors' 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/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -40,6 +40,7 @@ from mercurial import (
     merge as mergemod,
     mergeutil,
     obsolete,
+    obsutil,
     patch,
     phases,
     registrar,
@@ -1474,7 +1475,7 @@ def _computeobsoletenotrebased(repo, reb
     cl = repo.changelog
     for r in rebaseobsrevs:
         node = cl.node(r)
-        for s in obsolete.allsuccessors(repo.obsstore, [node]):
+        for s in obsutil.allsuccessors(repo.obsstore, [node]):
             try:
                 allsuccessors[cl.rev(s)] = cl.rev(node)
             except LookupError:
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -869,27 +869,6 @@ def successormarkers(ctx):
     for data in ctx.repo().obsstore.successors.get(ctx.node(), ()):
         yield marker(ctx.repo(), data)
 
-def allsuccessors(obsstore, nodes, ignoreflags=0):
-    """Yield node for every successor of <nodes>.
-
-    Some successors may be unknown locally.
-
-    This is a linear yield unsuited to detecting split changesets. It includes
-    initial nodes too."""
-    remaining = set(nodes)
-    seen = set(remaining)
-    while remaining:
-        current = remaining.pop()
-        yield current
-        for mark in obsstore.successors.get(current, ()):
-            # ignore marker flagged with specified flag
-            if mark[2] & ignoreflags:
-                continue
-            for suc in mark[1]:
-                if suc not in seen:
-                    seen.add(suc)
-                    remaining.add(suc)
-
 def foreground(repo, nodes):
     """return all nodes in the "foreground" of other node
 
@@ -911,7 +890,7 @@ def foreground(repo, nodes):
             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))
+            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)
@@ -922,6 +901,11 @@ def allprecursors(obsstore, nodes, ignor
     util.nouideprecwarn(movemsg, '4.3')
     return obsutil.allprecursors(obsstore, nodes, ignoreflags)
 
+def allsuccessors(obsstore, nodes, ignoreflags=0):
+    movemsg = 'obsolete.allsuccessors moved to obsutil.allsuccessors'
+    util.nouideprecwarn(movemsg, '4.3')
+    return obsutil.allsuccessors(obsstore, nodes, ignoreflags)
+
 def exclusivemarkers(repo, nodes):
     movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers'
     repo.ui.deprecwarn(movemsg, '4.3')
diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -57,6 +57,27 @@ def allprecursors(obsstore, nodes, ignor
                 seen.add(suc)
                 remaining.add(suc)
 
+def allsuccessors(obsstore, nodes, ignoreflags=0):
+    """Yield node for every successor of <nodes>.
+
+    Some successors may be unknown locally.
+
+    This is a linear yield unsuited to detecting split changesets. It includes
+    initial nodes too."""
+    remaining = set(nodes)
+    seen = set(remaining)
+    while remaining:
+        current = remaining.pop()
+        yield current
+        for mark in obsstore.successors.get(current, ()):
+            # ignore marker flagged with specified flag
+            if mark[2] & ignoreflags:
+                continue
+            for suc in mark[1]:
+                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