obsolete: add an any successors function
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 17 Jul 2012 17:31:29 +0200
changeset 17213 7eb5aa1f83fd
parent 17212 246131d670c2
child 17214 738ad56dd8a6
obsolete: add an any successors function This function yield every nodes which succeed to a group of nodes. The first user will be checkheads who need to know if we push successors for remote extra heads.
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Tue Jul 17 18:14:16 2012 +0200
+++ b/mercurial/obsolete.py	Tue Jul 17 17:31:29 2012 +0200
@@ -285,3 +285,17 @@
     for data in ctx._repo.obsstore.successors.get(ctx.node(), ()):
         yield marker(ctx._repo, data)
 
+def anysuccessors(obsstore, node):
+    """Yield every successor of <node>
+
+    This this a linear yield unsuitable to detect splitted changeset."""
+    remaining = set([node])
+    seen = set(remaining)
+    while remaining:
+        current = remaining.pop()
+        yield current
+        for mark in obsstore.precursors.get(current, ()):
+            for suc in mark[1]:
+                if suc not in seen:
+                    seen.add(suc)
+                    remaining.add(suc)