mercurial/obsutil.py
changeset 33150 d0e5bf12f314
parent 33149 d09ae850296d
child 33151 0a370b93cca2
--- a/mercurial/obsutil.py	Tue Jun 27 01:11:56 2017 +0200
+++ b/mercurial/obsutil.py	Tue Jun 27 01:31:18 2017 +0200
@@ -35,6 +35,28 @@
             else:
                 stack.append(precnodeid)
 
+def allprecursors(obsstore, nodes, ignoreflags=0):
+    """Yield node for every precursors of <nodes>.
+
+    Some precursors may be unknown locally.
+
+    This is a linear yield unsuited to detecting folded changesets. It includes
+    initial nodes too."""
+
+    remaining = set(nodes)
+    seen = set(remaining)
+    while remaining:
+        current = remaining.pop()
+        yield current
+        for mark in obsstore.precursors.get(current, ()):
+            # ignore marker flagged with specified flag
+            if mark[2] & ignoreflags:
+                continue
+            suc = mark[0]
+            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])