D5360: rebase: fix dir/file conflict detection when using in-mem merge

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Dec 4 07:16:05 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG44c2e80db985: rebase: fix dir/file conflict detection when using in-mem merge (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5360?vs=12685&id=12691

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

AFFECTED FILES
  mercurial/context.py
  tests/test-rebase-inmemory.t

CHANGE DETAILS

diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -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 ..
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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 "



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list