diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1712,6 +1712,27 @@ if not complete: numupdates += 1 tocomplete.append((f, args, msg)) + else: + action = mresult.getfile(f)[0] + if action in ( + mergestatemod.ACTION_DELETED_CHANGED, + mergestatemod.ACTION_CHANGED_DELETED, + ): + # the merge was conflicting and either the mergetool + # choosed by the user or the user themselves on the prompt + # made a choice. + # If the changed file was kept, at commit we end up using + # the same filelog. This is not completely correct behavior + # as the new file post merge also represents that a + # conflicting change-delete merge was resolved in it's + # favor. Hence we will like to create a new filenode for + # that. Let's store this in mergestate extras + repo.ui.debug( + b"file %s had %s conflicts and mergetool resolved it, storing info in commitinfo\n" + % (f, action) + ) + + ms.addcommitinfo(f, {b'MERGE_DELETE_CANDIDATE': b'yes'}) # merge for f, args, msg in tocomplete: diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t --- a/tests/test-merge-criss-cross.t +++ b/tests/test-merge-criss-cross.t @@ -534,6 +534,7 @@ local path: the-file (hash 0000000000000000000000000000000000000000, flags "") ancestor path: the-file (node 4b69178b9bdae28b651393b46e631427a72f217a) other path: the-file (node 59e363a07dc876278f0e41756236f30213b6b460) + extra: MERGE_DELETE_CANDIDATE = yes extra: ancestorlinknode = 955800955977bd6c103836ee3e437276e940a589 extra: other-file (filenode-source = other) $ hg ci -m "merge-deleting-the-file-from-deleted" @@ -556,6 +557,7 @@ local path: the-file (hash 6d2e02da5a9fe0691363dc6b573845fa271eaa35, flags "") ancestor path: the-file (node 4b69178b9bdae28b651393b46e631427a72f217a) other path: the-file (node 0000000000000000000000000000000000000000) + extra: MERGE_DELETE_CANDIDATE = yes extra: ancestorlinknode = 955800955977bd6c103836ee3e437276e940a589 $ hg ci -m "merge-deleting-the-file-from-updated" created new head @@ -578,6 +580,7 @@ local path: the-file (hash 0000000000000000000000000000000000000000, flags "") ancestor path: the-file (node 4b69178b9bdae28b651393b46e631427a72f217a) other path: the-file (node 59e363a07dc876278f0e41756236f30213b6b460) + extra: MERGE_DELETE_CANDIDATE = yes extra: ancestorlinknode = 955800955977bd6c103836ee3e437276e940a589 extra: other-file (filenode-source = other) $ hg ci -m "merge-keeping-the-file-from-deleted" @@ -607,6 +610,7 @@ local path: the-file (hash 6d2e02da5a9fe0691363dc6b573845fa271eaa35, flags "") ancestor path: the-file (node 4b69178b9bdae28b651393b46e631427a72f217a) other path: the-file (node 0000000000000000000000000000000000000000) + extra: MERGE_DELETE_CANDIDATE = yes extra: ancestorlinknode = 955800955977bd6c103836ee3e437276e940a589 $ hg ci -m "merge-keeping-the-file-from-updated" created new head