revset: allow rev(-1) to indicate null revision (BC) stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 10 Jan 2015 12:56:38 +0900
branchstable
changeset 23954 310222feb9a8
parent 23953 af73c05e735a
child 23955 8a29897d42d2
revset: allow rev(-1) to indicate null revision (BC) This can simplify the conversion from numeric revision to string. Without it, we have to handle -1 specially because repo['-1'] != repo[-1]. The -1 revision is not officially documented, but this change makes sense assuming that "rev(%d)" exists for scripting or third-party tools.
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Fri Jan 23 20:30:49 2015 -0800
+++ b/mercurial/revset.py	Sat Jan 10 12:56:38 2015 +0900
@@ -1545,7 +1545,7 @@
     except (TypeError, ValueError):
         # i18n: "rev" is a keyword
         raise error.ParseError(_("rev expects a number"))
-    if l not in fullreposet(repo):
+    if l not in fullreposet(repo) and l != node.nullrev:
         return baseset()
     return subset & baseset([l])
 
--- a/tests/test-revset.t	Fri Jan 23 20:30:49 2015 -0800
+++ b/tests/test-revset.t	Sat Jan 10 12:56:38 2015 +0900
@@ -465,7 +465,9 @@
   9
 
 Test explicit numeric revision
+  $ log 'rev(-2)'
   $ log 'rev(-1)'
+  -1
   $ log 'rev(0)'
   0
   $ log 'rev(9)'