copies: deal with the "same revision" special case earlier
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 14 Dec 2020 02:03:36 +0100
changeset 46183 ee63c1173c1b
parent 46182 dc4564ee57dc
child 46184 cb8b2ee89a5d
copies: deal with the "same revision" special case earlier This can happens a lot in case of deletion so we better deal with it early. Differential Revision: https://phab.mercurial-scm.org/D9592
mercurial/copies.py
--- a/mercurial/copies.py	Sun Dec 20 15:47:02 2020 +0100
+++ b/mercurial/copies.py	Mon Dec 14 02:03:36 2020 +0100
@@ -478,15 +478,19 @@
 
 def _compare_values(changes, isancestor, dest, minor, major):
     """compare two value within a _merge_copies_dict loop iteration"""
-    major_tt = major[0]
-    minor_tt = minor[0]
+    major_tt, major_value = major
+    minor_tt, minor_value = minor
 
-    if major[1] == minor[1]:
+    # evacuate some simple case first:
+    if major_tt == minor_tt:
+        # if it comes from the same revision it must be the same value
+        assert major_value == minor_value
         return PICK_EITHER
-    # content from "major" wins, unless it is older
-    # than the branch point or there is a merge
-    if major_tt == minor_tt:
-        return PICK_MAJOR
+    elif major[1] == minor[1]:
+        return PICK_EITHER
+
+    # actual merging needed: content from "major" wins, unless it is older than
+    # the branch point or there is a merge
     elif changes is not None and major[1] is None and dest in changes.salvaged:
         return PICK_MINOR
     elif changes is not None and minor[1] is None and dest in changes.salvaged: