Patchwork D2940: workingctx: build _manifest on filenode() or flags() request

login
register
mail settings
Submitter phabricator
Date March 25, 2018, 9:54 a.m.
Message ID <differential-rev-PHID-DREV-jtui5bfvstb2kt7tupj4-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29846/
State Superseded
Headers show

Comments

phabricator - March 25, 2018, 9:54 a.m.
yuja created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I'm not sure if this is the best workaround, but this fixes the following
  exception:
  
    AttributeError: 'workingctx' object has no attribute '_manifestdelta'
  
  The short hash '303030303030' seen in the test is node.modifiednodeid.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py
  tests/test-grep.t

CHANGE DETAILS




To: yuja, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -237,6 +237,17 @@ 
   $ hg grep -f port
   [1]
 
+Test wdir
+(at least, this shouldn't crash)
+
+  $ hg up -q
+  $ echo wport >> port2
+  $ hg stat
+  M port2
+  $ hg grep -r 'wdir()' port
+  abort: data/port2.i@303030303030: no node!
+  [255]
+
   $ cd ..
   $ hg init t2
   $ cd t2
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1378,6 +1378,11 @@ 
             p = p[:-1]
         return [changectx(self._repo, x) for x in p]
 
+    def _fileinfo(self, path):
+        # populate __dict__['_manifest'] as workingctx has no _manifestdelta
+        self._manifest
+        return super(workingctx, self)._fileinfo(path)
+
     def filectx(self, path, filelog=None):
         """get a file context from the working directory"""
         return workingfilectx(self._repo, path, workingctx=self,