Patchwork merge: perform case-collision checking on final set of actions

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 13, 2014, 1:39 a.m.
Message ID <b4c4f7028eb1cac2f89c.1418434794@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7073/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Dec. 13, 2014, 1:39 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1415973184 28800
#      Fri Nov 14 05:53:04 2014 -0800
# Node ID b4c4f7028eb1cac2f89cecab2036e5d95334622f
# Parent  495bc1b65d25872324a0220354f048b220304bd1
merge: perform case-collision checking on final set of actions

When there are multiple common ancestors, we should check for case
collisions only on the resulting actions after bid merge has run. To
do this, move the code until after bid merge.

Move it past _resolvetrivial() too, since that might update
actions. If the remote changed a file and then reverted the change,
while the local side deleted the file and created a new file with a
name that case-folds like the old file, we should fail before this
patch but not after.

Although the changes to the actions caused by _forgetremoved() should
have no effect on case collisions, move it after that, too, so the
next person reading the code won't have to think about it.

Moving it past these blocks of code takes it to the end of
calculateupdates(), so let's even move it outside of the method, so we
also check collisions in actions produced by extensions overriding the
method.
Pierre-Yves David - Dec. 13, 2014, 8:06 p.m.
On 12/12/2014 05:39 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1415973184 28800
> #      Fri Nov 14 05:53:04 2014 -0800
> # Node ID b4c4f7028eb1cac2f89cecab2036e5d95334622f
> # Parent  495bc1b65d25872324a0220354f048b220304bd1
> merge: perform case-collision checking on final set of actions

Pushed to the clowncopter, thanks.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -527,14 +527,6 @@ 
         raise util.Abort(_("untracked files in working directory differ "
                            "from files in requested revision"))
 
-    if not util.checkcase(repo.path):
-        # check collision between files only in p2 for clean update
-        if (not branchmerge and
-            (force or not wctx.dirty(missing=True, branch=False))):
-            _checkcollision(repo, m2, None)
-        else:
-            _checkcollision(repo, m1, actions)
-
     return actions, diverge, renamedelete
 
 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
@@ -1091,6 +1083,14 @@ 
             repo, wc, p2, pas, branchmerge, force, partial, mergeancestor,
             followcopies)
 
+        if not util.checkcase(repo.path):
+            # check collision between files only in p2 for clean update
+            if (not branchmerge and
+                (force or not wc.dirty(missing=True, branch=False))):
+                _checkcollision(repo, p2.manifest(), None)
+            else:
+                _checkcollision(repo, wc.manifest(), actions)
+
         # Prompt and create actions. TODO: Move this towards resolve phase.
         for f, args, msg in sorted(actions['cd']):
             if repo.ui.promptchoice(