Patchwork D6217: remotefilelog: correctly reject wdir filenodes

login
register
mail settings
Submitter phabricator
Date April 8, 2019, 3 p.m.
Message ID <differential-rev-PHID-DREV-usrgt7qdnrihp74kq5qf-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39534/
State Superseded
Headers show

Comments

phabricator - April 8, 2019, 3 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This fixes `hg grep -r 'wdir()'` when remotefilelog is enabled and the working
  directory contains uncommitted modifications.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6217

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  tests/test-remotefilelog-blame.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - April 8, 2019, 10:07 p.m.
martinvonz added inline comments.

INLINE COMMENTS

> test-remotefilelog-blame.t:40
>    $ 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

dropping the leading `+` in flight :)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6217

To: durin42, #hg-reviewers
Cc: martinvonz, mercurial-devel

Patch

diff --git a/tests/test-remotefilelog-blame.t b/tests/test-remotefilelog-blame.t
--- a/tests/test-remotefilelog-blame.t
+++ b/tests/test-remotefilelog-blame.t
@@ -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
diff --git a/hgext/remotefilelog/remotefilelog.py b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -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)