revlog: detect pseudo file nodeids to raise WdirUnsupported exception
authorYuya Nishihara <yuya@tcha.org>
Sun, 25 Mar 2018 18:34:07 +0900
changeset 37449 a0d71618074f
parent 37448 d7114f883505
child 37450 81d35d5d35f9
revlog: detect pseudo file nodeids to raise WdirUnsupported exception Again, I'm not sure if this is the right thing, but adding a few more pseudo hashes wouldn't be any worse than the current state. Differential Revision: https://phab.mercurial-scm.org/D2942
mercurial/revlog.py
tests/test-grep.t
--- a/mercurial/revlog.py	Sun Mar 25 18:31:22 2018 +0900
+++ b/mercurial/revlog.py	Sun Mar 25 18:34:07 2018 +0900
@@ -29,6 +29,7 @@
     hex,
     nullid,
     nullrev,
+    wdirfilenodeids,
     wdirhex,
     wdirid,
     wdirrev,
@@ -807,7 +808,7 @@
             raise
         except RevlogError:
             # parsers.c radix tree lookup failed
-            if node == wdirid:
+            if node == wdirid or node in wdirfilenodeids:
                 raise error.WdirUnsupported
             raise LookupError(node, self.indexfile, _('no node'))
         except KeyError:
@@ -823,7 +824,7 @@
                 if v == node:
                     self._nodepos = r - 1
                     return r
-            if node == wdirid:
+            if node == wdirid or node in wdirfilenodeids:
                 raise error.WdirUnsupported
             raise LookupError(node, self.indexfile, _('no node'))
 
@@ -1436,6 +1437,7 @@
                 pass
 
     def _partialmatch(self, id):
+        # we don't care wdirfilenodeids as they should be always full hash
         maybewdir = wdirhex.startswith(id)
         try:
             partial = self.index.partialmatch(id)
@@ -2114,7 +2116,7 @@
         if node == nullid:
             raise RevlogError(_("%s: attempt to add null revision") %
                               (self.indexfile))
-        if node == wdirid:
+        if node == wdirid or node in wdirfilenodeids:
             raise RevlogError(_("%s: attempt to add wdir revision") %
                               (self.indexfile))
 
--- a/tests/test-grep.t	Sun Mar 25 18:31:22 2018 +0900
+++ b/tests/test-grep.t	Sun Mar 25 18:34:07 2018 +0900
@@ -245,7 +245,7 @@
   $ hg stat
   M port2
   $ hg grep -r 'wdir()' port
-  abort: data/port2.i@303030303030: no node!
+  abort: working directory revision cannot be specified
   [255]
 
   $ cd ..