[PATCH 03 of 10 V4] obsolete: have `anysuccessors` takes a list of nodes

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 18 17:52:26 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1350395398 -7200
# Node ID d17f98db8c9810891717e2aec4154f591ce07dcd
# Parent  262e7f38ae37d02870d8e126c93dab844c094a64
obsolete: have `anysuccessors` takes a list of nodes

Additional logic, used to detect mutable history troubles, will need to quickly
compute successors of a whole set of changeset.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -267,7 +267,7 @@
                 if c.phase() > phases.public:
                     # obsolescence marker does not apply to public changeset
                     succs.update(obsolete.allsuccessors(repo.obsstore,
-                                                        c.node()))
+                                                        [c.node()]))
             validdests = set(repo.set('%ln::', succs))
         validdests.remove(old)
         return new in validdests
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -298,7 +298,7 @@
                 if nh in repo and repo[nh].phase() <= phases.public:
                     newhs.add(nh)
                 else:
-                    for suc in obsolete.allsuccessors(repo.obsstore, nh):
+                    for suc in obsolete.allsuccessors(repo.obsstore, [nh]):
                         if suc != nh and suc in allfuturecommon:
                             discardedheads.add(nh)
                             break
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -351,11 +351,13 @@
     for data in ctx._repo.obsstore.successors.get(ctx.node(), ()):
         yield marker(ctx._repo, data)
 
-def allsuccessors(obsstore, node):
-    """Yield every successor of <node>
+def allsuccessors(obsstore, nodes):
+    """Yield node for every successor of <nodes>.
+
+    Some successors may be unknown locally.
 
     This is a linear yield unsuited to detecting split changesets."""
-    remaining = set([node])
+    remaining = set(nodes)
     seen = set(remaining)
     while remaining:
         current = remaining.pop()


More information about the Mercurial-devel mailing list