Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 40819:cb372d09d30a
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 04 Dec 2018 17:13:01 -0500 |
parents | d98fb3f42f33 1c8c54cf9725 |
children | 789515904b03 |
comparison
equal
deleted
inserted
replaced
40811:e13ab4acf555 | 40819:cb372d09d30a |
---|---|
1841 raise error.ProgrammingError("No such file or directory: %s" % | 1841 raise error.ProgrammingError("No such file or directory: %s" % |
1842 self._path) | 1842 self._path) |
1843 else: | 1843 else: |
1844 return self._wrappedctx[path].flags() | 1844 return self._wrappedctx[path].flags() |
1845 | 1845 |
1846 def __contains__(self, key): | |
1847 if key in self._cache: | |
1848 return self._cache[key]['exists'] | |
1849 return key in self.p1() | |
1850 | |
1846 def _existsinparent(self, path): | 1851 def _existsinparent(self, path): |
1847 try: | 1852 try: |
1848 # ``commitctx` raises a ``ManifestLookupError`` if a path does not | 1853 # ``commitctx` raises a ``ManifestLookupError`` if a path does not |
1849 # exist, unlike ``workingctx``, which returns a ``workingfilectx`` | 1854 # exist, unlike ``workingctx``, which returns a ``workingfilectx`` |
1850 # with an ``exists()`` function. | 1855 # with an ``exists()`` function. |
1875 # Test that each new directory to be created to write this path from p2 | 1880 # Test that each new directory to be created to write this path from p2 |
1876 # is not a file in p1. | 1881 # is not a file in p1. |
1877 components = path.split('/') | 1882 components = path.split('/') |
1878 for i in pycompat.xrange(len(components)): | 1883 for i in pycompat.xrange(len(components)): |
1879 component = "/".join(components[0:i]) | 1884 component = "/".join(components[0:i]) |
1880 if component in self.p1() and self._cache[component]['exists']: | 1885 if component in self: |
1881 fail(path, component) | 1886 fail(path, component) |
1882 | 1887 |
1883 # Test the other direction -- that this path from p2 isn't a directory | 1888 # Test the other direction -- that this path from p2 isn't a directory |
1884 # in p1 (test that p1 doesn't any paths matching `path/*`). | 1889 # in p1 (test that p1 doesn't have any paths matching `path/*`). |
1885 match = matchmod.match('/', '', [path + '/'], default=b'relpath') | 1890 match = self.match(pats=[path + '/'], default=b'path') |
1886 matches = self.p1().manifest().matches(match) | 1891 matches = self.p1().manifest().matches(match) |
1887 mfiles = matches.keys() | 1892 mfiles = matches.keys() |
1888 if len(mfiles) > 0: | 1893 if len(mfiles) > 0: |
1889 if len(mfiles) == 1 and mfiles[0] == path: | 1894 if len(mfiles) == 1 and mfiles[0] == path: |
1890 return | 1895 return |
1891 # omit the files which are deleted in current IMM wctx | 1896 # omit the files which are deleted in current IMM wctx |
1892 mfiles = [m for m in mfiles if self._cache[m]['exists']] | 1897 mfiles = [m for m in mfiles if m in self] |
1893 if not mfiles: | 1898 if not mfiles: |
1894 return | 1899 return |
1895 raise error.Abort("error: file '%s' cannot be written because " | 1900 raise error.Abort("error: file '%s' cannot be written because " |
1896 " '%s/' is a folder in %s (containing %d " | 1901 " '%s/' is a folder in %s (containing %d " |
1897 "entries: %s)" | 1902 "entries: %s)" |