changeset 48516:59524cb1cd73

simplemerge: don't calculate conflict labels when resolving automatically Differential Revision: https://phab.mercurial-scm.org/D11903
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 07 Dec 2021 23:01:20 -0800
parents bd27dad294b7
children 99a0b5422cf5
files mercurial/simplemerge.py
diffstat 1 files changed, 17 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/simplemerge.py	Tue Dec 07 22:45:31 2021 -0800
+++ b/mercurial/simplemerge.py	Tue Dec 07 23:01:20 2021 -0800
@@ -503,13 +503,6 @@
         # repository usually sees) might be more useful.
         return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
 
-    mode = opts.get('mode', b'merge')
-    name_a, name_b, name_base = None, None, None
-    if mode != b'union':
-        name_a, name_b, name_base = _picklabels(
-            [localctx.path(), otherctx.path(), None], opts.get('label', [])
-        )
-
     try:
         localtext = readctx(localctx)
         basetext = readctx(basectx)
@@ -519,26 +512,31 @@
 
     m3 = Merge3Text(basetext, localtext, othertext)
     conflicts = False
+    mode = opts.get('mode', b'merge')
     if mode == b'union':
         lines = _resolve(m3, (1, 2))
     elif mode == b'local':
         lines = _resolve(m3, (1,))
     elif mode == b'other':
         lines = _resolve(m3, (2,))
-    elif mode == b'mergediff':
-        lines, conflicts = _mergediff(m3, name_a, name_b, name_base)
     else:
-        extrakwargs = {
-            'minimize': True,
-        }
-        if name_base is not None:
-            extrakwargs['base_marker'] = b'|||||||'
-            extrakwargs['name_base'] = name_base
-            extrakwargs['minimize'] = False
-        lines = list(
-            m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs)
+        name_a, name_b, name_base = _picklabels(
+            [localctx.path(), otherctx.path(), None], opts.get('label', [])
         )
-        conflicts = m3.conflicts
+        if mode == b'mergediff':
+            lines, conflicts = _mergediff(m3, name_a, name_b, name_base)
+        else:
+            extrakwargs = {
+                'minimize': True,
+            }
+            if name_base is not None:
+                extrakwargs['base_marker'] = b'|||||||'
+                extrakwargs['name_base'] = name_base
+                extrakwargs['minimize'] = False
+            lines = list(
+                m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs)
+            )
+            conflicts = m3.conflicts
 
     mergedtext = b''.join(lines)
     if opts.get('print'):