Patchwork [4,of,8] obsutil: move 'allsuccessors' to the new modules

login
register
mail settings
Submitter Pierre-Yves David
Date June 27, 2017, 8:56 a.m.
Message ID <81137fb5e9ef24aec594.1498553807@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21763/
State Superseded
Headers show

Comments

Pierre-Yves David - June 27, 2017, 8:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1498520180 -7200
#      Tue Jun 27 01:36:20 2017 +0200
# Node ID 81137fb5e9ef24aec5940e08a5f5b17ac7576da0
# Parent  96f8f9e1d0a442a73dd6e205179a6d6390fd3c02
# 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 81137fb5e9ef
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.

Patch

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,
@@ -1470,7 +1471,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])