diff mercurial/filemerge.py @ 48578:77e24ee8994b

simplemerge: take arguments as annotated context objects The labels we put in conflict markers are formatted so the part before the ':' (typically says things like "local") is padded so the ':' is aligned among the labels. That means that if you specify a long label for "base" but the conflict marker style is "merge" (i.e. 2-way), the other two will have unwanted padding. We often don't specify a label for the base, so we don't notice the problem (and it may very well be that it didn't exist before my D11972). I think the best fix is to pass the labels along with the context objects, so the low-level code that switches on the marker style to use (i.e. `simplemerge`) can do the formatting. This patch starts doing that by passing a fully-formatted label to `simplemerge`. A coming patch will move the formatting to `simplemerge`. Differential Revision: https://phab.mercurial-scm.org/D12013
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 20 Jan 2022 11:00:30 -0800
parents 62682662346c
children f970bc616ebc
line wrap: on
line diff
--- a/mercurial/filemerge.py	Thu Jan 20 09:04:39 2022 -0800
+++ b/mercurial/filemerge.py	Thu Jan 20 11:00:30 2022 -0800
@@ -428,8 +428,11 @@
             mode = b'mergediff'
         elif premerge == b'keep-merge3':
             mode = b'merge3'
+        local = simplemerge.MergeInput(fcd, labels[0])
+        other = simplemerge.MergeInput(fco, labels[1])
+        base = simplemerge.MergeInput(fca, labels[2])
         r = simplemerge.simplemerge(
-            ui, fcd, fca, fco, quiet=True, label=labels, mode=mode
+            ui, local, base, other, quiet=True, mode=mode
         )
         if not r:
             ui.debug(b" premerge successful\n")
@@ -469,7 +472,16 @@
     of merge, unless mode equals 'union' which suppresses the markers."""
     ui = repo.ui
 
-    r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode)
+    local = simplemerge.MergeInput(fcd)
+    if len(labels) > 0:
+        local.label = labels[0]
+    other = simplemerge.MergeInput(fco)
+    if len(labels) > 1:
+        other.label = labels[1]
+    base = simplemerge.MergeInput(fca)
+    if len(labels) > 2:
+        base.label = labels[2]
+    r = simplemerge.simplemerge(ui, local, base, other, mode=mode)
     return True, r, False