revset: add support for using ~ operator on wdir() predicate
We catch the WdirUnsupported exception and handles the wdir() case here.
--- 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())'