changeset 42095:864f9f63d3ed

remotefilelog: correctly reject wdir filenodes This fixes `hg grep -r 'wdir()'` when remotefilelog is enabled and the working directory contains uncommitted modifications. Differential Revision: https://phab.mercurial-scm.org/D6217
author Augie Fackler <augie@google.com>
date Mon, 08 Apr 2019 10:52:04 -0400
parents b1b216a241cc
children 509a0477b3a6
files hgext/remotefilelog/remotefilelog.py tests/test-remotefilelog-blame.t
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/remotefilelog.py	Mon Apr 08 10:56:55 2019 -0400
+++ b/hgext/remotefilelog/remotefilelog.py	Mon Apr 08 10:52:04 2019 -0400
@@ -10,7 +10,12 @@
 import collections
 import os
 
-from mercurial.node import bin, nullid
+from mercurial.node import (
+    bin,
+    nullid,
+    wdirfilenodeids,
+    wdirid,
+)
 from mercurial.i18n import _
 from mercurial import (
     ancestor,
@@ -306,6 +311,8 @@
         if len(node) != 20:
             raise error.LookupError(node, self.filename,
                                     _('invalid revision input'))
+        if node == wdirid or node in wdirfilenodeids:
+            raise error.WdirUnsupported
 
         store = self.repo.contentstore
         rawtext = store.get(self.filename, node)
--- a/tests/test-remotefilelog-blame.t	Mon Apr 08 10:56:55 2019 -0400
+++ b/tests/test-remotefilelog-blame.t	Mon Apr 08 10:52:04 2019 -0400
@@ -35,11 +35,6 @@
 
   $ hg grep --all-files x
   x:x
-BROKEN: modifications in the wdir tries to fetch from the server.
   $ echo foo >> x
   $ hg grep --all-files x
-  remote: abort: working directory revision cannot be specified
-  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
-  abort: error downloading file contents:
-  'connection closed early'
-  [255]
+  x:x