[Request] [+ ] D12152: simplemerge: replace `**opts` by a single `mode` argument

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Feb 8 21:28:22 UTC 2022


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

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']:



To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220208/2292e204/attachment-0001.html>


More information about the Mercurial-patches mailing list