# HG changeset patch # User Martin von Zweigbergk # Date 1592891263 25200 # Node ID 58e7ee23ddbd2e90ce4a256a2f2d182c03d0b73e # Parent 4b79e92a5ef8dcb02d2266e6f1c3c94ee90db2c7 copies: handle more cases where a file got replaced by a copy This patch fixes the changeset-centric version in a pretty straight-forward way. It fixes it to automatically resolve the conflict, which is better than resulting in a modify/delete conflict as it was before b4057d001760 (merge: when rename was made on both sides, use ancestor as merge base, 2020-01-22). I'll leave it for later to test and explicitly handle cases where files have been renamed to the same target on different sides of the merge. Differential Revision: https://phab.mercurial-scm.org/D8653 diff -r 4b79e92a5ef8 -r 58e7ee23ddbd mercurial/merge.py --- a/mercurial/merge.py Mon Jun 22 22:47:33 2020 -0700 +++ b/mercurial/merge.py Mon Jun 22 22:47:43 2020 -0700 @@ -817,6 +817,22 @@ args = (f, f, None, False, pa.node()) msg = b'both created' mresult.addfile(f, mergestatemod.ACTION_MERGE, args, msg) + elif f in branch_copies1.copy: + fa = branch_copies1.copy[f] + mresult.addfile( + f, + mergestatemod.ACTION_MERGE, + (f, fa, fa, False, pa.node()), + b'local replaced from %s' % fa, + ) + elif f in branch_copies2.copy: + fa = branch_copies2.copy[f] + mresult.addfile( + f, + mergestatemod.ACTION_MERGE, + (fa, f, fa, False, pa.node()), + b'other replaced from %s' % fa, + ) else: a = ma[f] fla = ma.flags(f) diff -r 4b79e92a5ef8 -r 58e7ee23ddbd tests/test-copies.t --- a/tests/test-copies.t Mon Jun 22 22:47:33 2020 -0700 +++ b/tests/test-copies.t Mon Jun 22 22:47:43 2020 -0700 @@ -496,16 +496,17 @@ 1 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon [1] -BROKEN: should be "modified" +This should ideally be "modified", but we will probably not be able to fix +that in the filelog case. $ cat y original #else $ hg merge 2 - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + merging x and y to y + 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) -BROKEN: should be "modified" $ cat y - original + modified #endif Same as above, but in the opposite direction #if filelog @@ -523,11 +524,11 @@ #else $ hg co -qC 2 $ hg merge 3 - 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + merging y and x to y + 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) -BROKEN: should be "modified" $ cat y - original + modified #endif Create x and y, then rename x to z on one side of merge, and rename y to z and