mercurial/revset.py
changeset 37001 407934a97bc7
parent 36607 c6061cadb400
child 37084 f0b6fbea00cf
--- a/mercurial/revset.py	Fri Jan 19 15:25:06 2018 +0100
+++ b/mercurial/revset.py	Fri Jan 19 16:52:02 2018 +0100
@@ -28,6 +28,7 @@
     revsetlang,
     scmutil,
     smartset,
+    stack,
     util,
 )
 from .utils import dateutil
@@ -1532,6 +1533,21 @@
     target = phases.secret
     return _phase(repo, subset, target)
 
+@predicate('stack([revs])', safe=True)
+def _stack(repo, subset, x):
+    # experimental revset for the stack of changesets or working directory
+    # parent
+    if x is None:
+        stacks = stack.getstack(repo, x)
+    else:
+        stacks = smartset.baseset([])
+        for revision in getset(repo, fullreposet(repo), x):
+            currentstack = stack.getstack(repo, revision)
+            stacks = stacks + currentstack
+
+    # Force to use the order of the stacks instead of the subset one
+    return stacks & subset
+
 def parentspec(repo, subset, x, n, order):
     """``set^0``
     The set.