[PATCH 6 of 7] revset: add support for integer and hex wdir identifiers

Yuya Nishihara yuya at tcha.org
Sat Jun 3 10:39:30 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1496489973 -32400
#      Sat Jun 03 20:39:33 2017 +0900
# Node ID 1a10667a630c1558e2fe6b4ed081a4c5f7bf59f7
# Parent  cee3aecb6c45796eb7a79b995c04dd83289bfd76
revset: add support for integer and hex wdir identifiers

As I said before, partial 'ff...' hash isn't supported yet.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -24,6 +24,7 @@ from . import (
     registrar,
     repoview,
     revsetlang,
+    scmutil,
     smartset,
     util,
 )
@@ -190,7 +191,7 @@ def _getrevsource(repo, r):
 # operator methods
 
 def stringset(repo, subset, x):
-    x = repo[x].rev()
+    x = scmutil.intrev(repo[x])
     if (x in subset
         or x == node.nullrev and isinstance(subset, fullreposet)):
         return baseset([x])
@@ -1297,13 +1298,18 @@ def node_(repo, subset, x):
     if len(n) == 40:
         try:
             rn = repo.changelog.rev(node.bin(n))
+        except error.WdirUnsupported:
+            rn = node.wdirrev
         except (LookupError, TypeError):
             rn = None
     else:
         rn = None
         pm = repo.changelog._partialmatch(n)
         if pm is not None:
-            rn = repo.changelog.rev(pm)
+            try:
+                rn = repo.changelog.rev(pm)
+            except error.WdirUnsupported:
+                rn = node.wdirrev
 
     if rn is None:
         return baseset()
@@ -1620,7 +1626,7 @@ def rev(repo, subset, x):
     except (TypeError, ValueError):
         # i18n: "rev" is a keyword
         raise error.ParseError(_("rev expects a number"))
-    if l not in repo.changelog and l != node.nullrev:
+    if l not in repo.changelog and l not in (node.nullrev, node.wdirrev):
         return baseset()
     return subset & baseset([l])
 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1280,6 +1280,20 @@ For tests consistency
   $ log '(all() + wdir()) & last(. + wdir())'
   2147483647
 
+Test working-directory integer revision and node id
+(BUG: '0:wdir()' is still needed to populate wdir revision)
+
+  $ hg debugrevspec '0:wdir() & 2147483647'
+  2147483647
+  $ hg debugrevspec '0:wdir() & rev(2147483647)'
+  2147483647
+  $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
+  2147483647
+  $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
+  2147483647
+  $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
+BROKEN: should be '2147483647'
+
   $ log 'outgoing()'
   8
   9


More information about the Mercurial-devel mailing list