simplemerge: don't calculate conflict labels when resolving automatically
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 07 Dec 2021 23:01:20 -0800
changeset 48516 59524cb1cd73
parent 48515 bd27dad294b7
child 48517 99a0b5422cf5
simplemerge: don't calculate conflict labels when resolving automatically Differential Revision: https://phab.mercurial-scm.org/D11903
mercurial/simplemerge.py
--- 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'):