revset: add support for ancestors(wdir())
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 23 May 2017 01:22:33 +0530
changeset 32442 4dd292cec3ad
parent 32441 018f638ad88e
child 32443 34e9b8b94f66
revset: add support for ancestors(wdir()) This is a part of extending support for wdir() predicate.
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Tue May 23 01:08:19 2017 +0530
+++ b/mercurial/revset.py	Tue May 23 01:22:33 2017 +0530
@@ -75,9 +75,14 @@
             if current not in seen:
                 seen.add(current)
                 yield current
-                for parent in cl.parentrevs(current)[:cut]:
-                    if parent != node.nullrev:
-                        heapq.heappush(h, -parent)
+                try:
+                    for parent in cl.parentrevs(current)[:cut]:
+                        if parent != node.nullrev:
+                            heapq.heappush(h, -parent)
+                except error.WdirUnsupported:
+                    for parent in repo[current].parents()[:cut]:
+                        if parent.rev() != node.nullrev:
+                            heapq.heappush(h, -parent.rev())
 
     return generatorset(iterate(), iterasc=False)
 
--- a/tests/test-revset.t	Tue May 23 01:08:19 2017 +0530
+++ b/tests/test-revset.t	Tue May 23 01:22:33 2017 +0530
@@ -1231,6 +1231,16 @@
   2147483647
   $ hg debugrevspec 'wdir()~3'
   5
+  $ hg debugrevspec 'ancestors(wdir())'
+  0
+  1
+  2
+  3
+  4
+  5
+  6
+  7
+  2147483647
   $ hg debugrevspec 'wdir()~0'
   2147483647
   $ hg debugrevspec 'p1(wdir())'