[PATCH 08 of 10] revset: add support for ancestors(wdir())

Pulkit Goyal 7895pulkit at gmail.com
Mon May 22 16:52:18 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1495482753 -19800
#      Tue May 23 01:22:33 2017 +0530
# Node ID 5a8f18940f9961debfde65c7c7fd66964580734d
# Parent  6ed3d53be6963cbd841fd2c04b4311a27a3c4b65
revset: add support for ancestors(wdir())

This is a part of extending support for wdir() predicate.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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)
 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -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())'


More information about the Mercurial-devel mailing list