simplemerge: move default labels to simplemerge extension
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 07 Jan 2022 23:29:19 -0800
changeset 48588 6ad70879d2bd
parent 48587 b5e1283c0475
child 48589 69e76b2aad3d
simplemerge: move default labels to simplemerge extension I want to remove knowledge of paths from the `simplemerge` core module. As part of that, let's move the default labels from the core module to the extension. Differential Revision: https://phab.mercurial-scm.org/D11977
contrib/simplemerge
mercurial/simplemerge.py
--- a/contrib/simplemerge	Fri Jan 07 22:23:44 2022 -0800
+++ b/contrib/simplemerge	Fri Jan 07 23:29:19 2022 -0800
@@ -83,6 +83,10 @@
     if len(opts[b'label']) > 2:
         opts[b'mode'] = b'merge3'
     local, base, other = args
+    overrides = opts[b'label']
+    labels = [local, other, base]
+    labels[: len(overrides)] = overrides
+    opts[b'label'] = labels
     sys.exit(
         simplemerge.simplemerge(
             uimod.ui.load(),
--- a/mercurial/simplemerge.py	Fri Jan 07 22:23:44 2022 -0800
+++ b/mercurial/simplemerge.py	Fri Jan 07 23:29:19 2022 -0800
@@ -332,10 +332,10 @@
     return text
 
 
-def _picklabels(defaults, overrides):
+def _picklabels(overrides):
     if len(overrides) > 3:
         raise error.Abort(_(b"can only specify three labels."))
-    result = defaults[:]
+    result = [None, None, None]
     for i, override in enumerate(overrides):
         result[i] = override
     return result
@@ -501,9 +501,7 @@
     elif mode == b'other':
         lines = _resolve(m3, (2,))
     else:
-        name_a, name_b, name_base = _picklabels(
-            [localctx.path(), otherctx.path(), None], opts.get('label', [])
-        )
+        name_a, name_b, name_base = _picklabels(opts.get('label', []))
         if mode == b'mergediff':
             lines, conflicts = render_mergediff(m3, name_a, name_b, name_base)
         else: