revset: allow repo.revs('%d', wdirrev)
authorYuya Nishihara <yuya@tcha.org>
Sat, 21 Mar 2020 13:27:47 +0900
changeset 44582 482a6aac1f15
parent 44581 b746a22349f9
child 44583 967e2e81f762
revset: allow repo.revs('%d', wdirrev) Otherwise we can't write repo.revs('null:%d', subset.max()) to build a smartset covering the range {null .. tip} + {wdir} if subset includes wdir.
mercurial/revset.py
tests/test-template-functions.t
--- a/mercurial/revset.py	Thu Mar 19 16:06:24 2020 +0100
+++ b/mercurial/revset.py	Sat Mar 21 13:27:47 2020 +0900
@@ -2108,7 +2108,8 @@
     except (TypeError, ValueError):
         # i18n: "rev" is a keyword
         raise error.ParseError(_(b"rev expects a number"))
-    repo.changelog.node(l)  # check that the rev exists
+    if l not in _virtualrevs:
+        repo.changelog.node(l)  # check that the rev exists
     return subset & baseset([l])
 
 
--- a/tests/test-template-functions.t	Thu Mar 19 16:06:24 2020 +0100
+++ b/tests/test-template-functions.t	Sat Mar 21 13:27:47 2020 +0900
@@ -1263,6 +1263,13 @@
   5:13207e5a10d9fd28ec424934298e176197f2c67f,
   4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
 
+%d parameter handling:
+
+  $ hg log -T '{revset("%d", rev)}\n' -r'wdir()'
+  2147483647
+  $ hg log -T '{revset("%d", rev)}\n' -r'null'
+  -1
+
 Invalid arguments passed to revset()
 
   $ hg log -T '{revset("%whatever", 0)}\n'