obsutil: move 'allsuccessors' to the new modules
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 27 Jun 2017 01:36:20 +0200
changeset 33145 0a370b93cca2
parent 33144 d0e5bf12f314
child 33146 7017567ebdf2
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.
hgext/rebase.py
mercurial/obsolete.py
mercurial/obsutil.py
--- a/hgext/rebase.py	Tue Jun 27 01:31:18 2017 +0200
+++ b/hgext/rebase.py	Tue Jun 27 01:36:20 2017 +0200
@@ -40,6 +40,7 @@
     merge as mergemod,
     mergeutil,
     obsolete,
+    obsutil,
     patch,
     phases,
     registrar,
@@ -1454,7 +1455,7 @@
     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:
--- a/mercurial/obsolete.py	Tue Jun 27 01:31:18 2017 +0200
+++ b/mercurial/obsolete.py	Tue Jun 27 01:36:20 2017 +0200
@@ -869,27 +869,6 @@
     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 @@
             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 @@
     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')
--- a/mercurial/obsutil.py	Tue Jun 27 01:31:18 2017 +0200
+++ b/mercurial/obsutil.py	Tue Jun 27 01:36:20 2017 +0200
@@ -57,6 +57,27 @@
                 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])