D11977: simplemerge: move default labels to simplemerge extension

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Jan 12 06:56:26 UTC 2022


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

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/simplemerge
  mercurial/simplemerge.py

CHANGE DETAILS

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



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


More information about the Mercurial-devel mailing list