Mercurial > hg
changeset 40803:44c2e80db985 stable
rebase: fix dir/file conflict detection when using in-mem merge
Differential Revision: https://phab.mercurial-scm.org/D5360
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 03 Dec 2018 11:14:44 -0800 |
parents | e204d9a27528 |
children | 9cdd525d97b2 |
files | mercurial/context.py tests/test-rebase-inmemory.t |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Mon Dec 03 11:11:34 2018 -0800 +++ b/mercurial/context.py Mon Dec 03 11:14:44 2018 -0800 @@ -1805,6 +1805,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 @@ -1839,7 +1844,7 @@ 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 @@ -1851,7 +1856,7 @@ 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 "
--- a/tests/test-rebase-inmemory.t Mon Dec 03 11:11:34 2018 -0800 +++ b/tests/test-rebase-inmemory.t Mon Dec 03 11:14:44 2018 -0800 @@ -243,12 +243,16 @@ $ echo c > c/c $ hg add c/c $ hg ci -m 'c/c' -BROKEN: This should be a conflict, should not crash - $ hg rebase -r . -d 3 -n 2>&1 | grep KeyError - KeyError: 'c' -BROKEN: This should be a conflict, should not crash - $ hg rebase -r 3 -d . -n 2>&1 | grep KeyError - KeyError: 'c/c' + $ hg rebase -r . -d 3 -n + starting dry-run rebase; repository will not be changed + rebasing 8:755f0104af9b "c/c" (tip) + abort: error: 'c/c' conflicts with file 'c' in 3. + [255] + $ hg rebase -r 3 -d . -n + starting dry-run rebase; repository will not be changed + rebasing 3:844a7de3e617 "c" + abort: error: file 'c' cannot be written because 'c/' is a folder in 755f0104af9b (containing 1 entries: c/c) + [255] $ cd ..