mercurial/context.py
branchstable
changeset 40803 44c2e80db985
parent 40302 af2306bf7d5d
child 40816 1c8c54cf9725
equal deleted inserted replaced
40802:e204d9a27528 40803:44c2e80db985
  1803                 raise error.ProgrammingError("No such file or directory: %s" %
  1803                 raise error.ProgrammingError("No such file or directory: %s" %
  1804                                              self._path)
  1804                                              self._path)
  1805         else:
  1805         else:
  1806             return self._wrappedctx[path].flags()
  1806             return self._wrappedctx[path].flags()
  1807 
  1807 
       
  1808     def __contains__(self, key):
       
  1809         if key in self._cache:
       
  1810             return self._cache[key]['exists']
       
  1811         return key in self.p1()
       
  1812 
  1808     def _existsinparent(self, path):
  1813     def _existsinparent(self, path):
  1809         try:
  1814         try:
  1810             # ``commitctx` raises a ``ManifestLookupError`` if a path does not
  1815             # ``commitctx` raises a ``ManifestLookupError`` if a path does not
  1811             # exist, unlike ``workingctx``, which returns a ``workingfilectx``
  1816             # exist, unlike ``workingctx``, which returns a ``workingfilectx``
  1812             # with an ``exists()`` function.
  1817             # with an ``exists()`` function.
  1837         # Test that each new directory to be created to write this path from p2
  1842         # Test that each new directory to be created to write this path from p2
  1838         # is not a file in p1.
  1843         # is not a file in p1.
  1839         components = path.split('/')
  1844         components = path.split('/')
  1840         for i in pycompat.xrange(len(components)):
  1845         for i in pycompat.xrange(len(components)):
  1841             component = "/".join(components[0:i])
  1846             component = "/".join(components[0:i])
  1842             if component in self.p1() and self._cache[component]['exists']:
  1847             if component in self:
  1843                 fail(path, component)
  1848                 fail(path, component)
  1844 
  1849 
  1845         # Test the other direction -- that this path from p2 isn't a directory
  1850         # Test the other direction -- that this path from p2 isn't a directory
  1846         # in p1 (test that p1 doesn't any paths matching `path/*`).
  1851         # in p1 (test that p1 doesn't any paths matching `path/*`).
  1847         match = matchmod.match('/', '', [path + '/'], default=b'relpath')
  1852         match = matchmod.match('/', '', [path + '/'], default=b'relpath')
  1849         mfiles = matches.keys()
  1854         mfiles = matches.keys()
  1850         if len(mfiles) > 0:
  1855         if len(mfiles) > 0:
  1851             if len(mfiles) == 1 and mfiles[0] == path:
  1856             if len(mfiles) == 1 and mfiles[0] == path:
  1852                 return
  1857                 return
  1853             # omit the files which are deleted in current IMM wctx
  1858             # omit the files which are deleted in current IMM wctx
  1854             mfiles = [m for m in mfiles if self._cache[m]['exists']]
  1859             mfiles = [m for m in mfiles if m in self]
  1855             if not mfiles:
  1860             if not mfiles:
  1856                 return
  1861                 return
  1857             raise error.Abort("error: file '%s' cannot be written because "
  1862             raise error.Abort("error: file '%s' cannot be written because "
  1858                               " '%s/' is a folder in %s (containing %d "
  1863                               " '%s/' is a folder in %s (containing %d "
  1859                               "entries: %s)"
  1864                               "entries: %s)"