diff mercurial/merge.py @ 45817:58e7ee23ddbd

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
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 22 Jun 2020 22:47:43 -0700
parents ed0ded64a8a9
children 721f765a34ac
line wrap: on
line diff
--- 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)