Patchwork D12152: simplemerge: replace `**opts` by a single `mode` argument

login
register
mail settings
Submitter phabricator
Date Feb. 8, 2022, 9:28 p.m.
Message ID <differential-rev-PHID-DREV-mrntjyw45fj6til5nlic-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50487/
State New
Headers show

Comments

phabricator - Feb. 8, 2022, 9:28 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We now only care about `opts['mode']`, so let's simplify the
  signature.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/simplemerge
  mercurial/simplemerge.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -495,7 +495,7 @@ 
                 raise error.Abort(msg)
 
 
-def simplemerge(local, base, other, **opts):
+def simplemerge(local, base, other, mode=b'merge'):
     """Performs the simplemerge algorithm.
 
     The merged result is written into `localctx`.
@@ -503,7 +503,6 @@ 
 
     m3 = Merge3Text(base.text(), local.text(), other.text())
     conflicts = False
-    mode = opts.get('mode', b'merge')
     if mode == b'union':
         lines = _resolve(m3, (1, 2))
     elif mode == b'local':
diff --git a/contrib/simplemerge b/contrib/simplemerge
--- a/contrib/simplemerge
+++ b/contrib/simplemerge
@@ -80,8 +80,9 @@ 
         sys.exit(0)
     if len(args) != 3:
         raise ParseError(_(b'wrong number of arguments').decode('utf8'))
+    mode = b'merge'
     if len(opts[b'label']) > 2:
-        opts[b'mode'] = b'merge3'
+        mode = b'merge3'
     local, base, other = args
     overrides = opts[b'label']
     if len(overrides) > 3:
@@ -107,7 +108,7 @@ 
         sys.exit(1)
 
     merged_text, conflicts = simplemerge.simplemerge(
-        local_input, base_input, other_input, **opts
+        local_input, base_input, other_input, mode=mode
     )
     if merged_text is not None:
         if opts['print']: