changeset 32441:018f638ad88e

revset: add support for using ~ operator on wdir() predicate We catch the WdirUnsupported exception and handles the wdir() case here.
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 23 May 2017 01:08:19 +0530
parents c8fb2a82b5f9
children 4dd292cec3ad
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Mon May 22 02:14:22 2017 +0530
+++ b/mercurial/revset.py	Tue May 23 01:08:19 2017 +0530
@@ -383,7 +383,10 @@
     cl = repo.changelog
     for r in getset(repo, fullreposet(repo), x):
         for i in range(n):
-            r = cl.parentrevs(r)[0]
+            try:
+                r = cl.parentrevs(r)[0]
+            except error.WdirUnsupported:
+                r = repo[r].parents()[0].rev()
         ps.add(r)
     return subset & ps
 
--- a/tests/test-revset.t	Mon May 22 02:14:22 2017 +0530
+++ b/tests/test-revset.t	Tue May 23 01:08:19 2017 +0530
@@ -1229,6 +1229,8 @@
   7
   $ hg debugrevspec 'wdir()^0'
   2147483647
+  $ hg debugrevspec 'wdir()~3'
+  5
   $ hg debugrevspec 'wdir()~0'
   2147483647
   $ hg debugrevspec 'p1(wdir())'