changeset 32442:4dd292cec3ad

revset: add support for ancestors(wdir()) This is a part of extending support for wdir() predicate.
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 23 May 2017 01:22:33 +0530
parents 018f638ad88e
children 34e9b8b94f66
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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())'