D11903: simplemerge: don't calculate conflict labels when resolving automatically

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Dec 11 02:02:10 UTC 2021


martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11903

AFFECTED FILES
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -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'):



To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list