Patchwork D1237: overlayworkingctx: add `_checkexist(path)`

login
register
mail settings
Submitter phabricator
Date Dec. 7, 2017, 10:16 p.m.
Message ID <853739dbecf859b394835e377490417d@localhost.localdomain>
Download mbox | patch
Permalink /patch/26059/
State Not Applicable
Headers show

Comments

phabricator - Dec. 7, 2017, 10:16 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbea46aed1e1b: overlayworkingctx: add `_checkexist(path)` (authored by phillco, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1237?vs=4202&id=4225

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2045,6 +2045,16 @@ 
         else:
             return self._wrappedctx[path].flags()
 
+    def _existsinparent(self, path):
+        try:
+            # ``commitctx` raises a ``ManifestLookupError`` if a path does not
+            # exist, unlike ``workingctx``, which returns a ``workingfilectx``
+            # with an ``exists()`` function.
+            self._wrappedctx[path]
+            return True
+        except error.ManifestLookupError:
+            return False
+
     def write(self, path, data, flags=''):
         if data is None:
             raise error.ProgrammingError("data must be non-None")
@@ -2070,13 +2080,15 @@ 
                 return self.exists(self._cache[path]['data'].strip())
             else:
                 return self._cache[path]['exists']
-        return self._wrappedctx[path].exists()
+
+        return self._existsinparent(path)
 
     def lexists(self, path):
         """lexists returns True if the path exists"""
         if self.isdirty(path):
             return self._cache[path]['exists']
-        return self._wrappedctx[path].lexists()
+
+        return self._existsinparent(path)
 
     def size(self, path):
         if self.isdirty(path):