revset: add support for using ~ operator on wdir() predicate
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 23 May 2017 01:08:19 +0530
changeset 32441 018f638ad88e
parent 32440 c8fb2a82b5f9
child 32442 4dd292cec3ad
revset: add support for using ~ operator on wdir() predicate We catch the WdirUnsupported exception and handles the wdir() case here.
mercurial/revset.py
tests/test-revset.t
--- 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())'