--- a/mercurial/context.py Thu Nov 29 09:13:13 2018 +0000
+++ b/mercurial/context.py Tue Dec 04 17:13:01 2018 -0500
@@ -1843,6 +1843,11 @@
else:
return self._wrappedctx[path].flags()
+ def __contains__(self, key):
+ if key in self._cache:
+ return self._cache[key]['exists']
+ return key in self.p1()
+
def _existsinparent(self, path):
try:
# ``commitctx` raises a ``ManifestLookupError`` if a path does not
@@ -1877,19 +1882,19 @@
components = path.split('/')
for i in pycompat.xrange(len(components)):
component = "/".join(components[0:i])
- if component in self.p1() and self._cache[component]['exists']:
+ if component in self:
fail(path, component)
# Test the other direction -- that this path from p2 isn't a directory
- # in p1 (test that p1 doesn't any paths matching `path/*`).
- match = matchmod.match('/', '', [path + '/'], default=b'relpath')
+ # in p1 (test that p1 doesn't have any paths matching `path/*`).
+ match = self.match(pats=[path + '/'], default=b'path')
matches = self.p1().manifest().matches(match)
mfiles = matches.keys()
if len(mfiles) > 0:
if len(mfiles) == 1 and mfiles[0] == path:
return
# omit the files which are deleted in current IMM wctx
- mfiles = [m for m in mfiles if self._cache[m]['exists']]
+ mfiles = [m for m in mfiles if m in self]
if not mfiles:
return
raise error.Abort("error: file '%s' cannot be written because "