##// END OF EJS Templates
simplemerge: replace `**opts` passed to `simplemerge()` by keyword arguments...
Martin von Zweigbergk -
r49593:9ee70e17 default
parent child Browse files
Show More
@@ -13,7 +13,6 b' from mercurial import ('
13 context,
13 context,
14 error,
14 error,
15 fancyopts,
15 fancyopts,
16 pycompat,
17 simplemerge,
16 simplemerge,
18 ui as uimod,
17 ui as uimod,
19 )
18 )
@@ -80,8 +79,9 b' try:'
80 sys.exit(0)
79 sys.exit(0)
81 if len(args) != 3:
80 if len(args) != 3:
82 raise ParseError(_(b'wrong number of arguments').decode('utf8'))
81 raise ParseError(_(b'wrong number of arguments').decode('utf8'))
82 mode = b'merge'
83 if len(opts[b'label']) > 2:
83 if len(opts[b'label']) > 2:
84 opts[b'mode'] = b'merge3'
84 mode = b'merge3'
85 local, base, other = args
85 local, base, other = args
86 overrides = opts[b'label']
86 overrides = opts[b'label']
87 if len(overrides) > 3:
87 if len(overrides) > 3:
@@ -103,7 +103,10 b' try:'
103 local_input,
103 local_input,
104 base_input,
104 base_input,
105 other_input,
105 other_input,
106 **pycompat.strkwargs(opts)
106 mode,
107 quiet=opts.get(b'quiet'),
108 allow_binary=opts.get(b'text'),
109 print_result=opts.get(b'print'),
107 )
110 )
108 )
111 )
109 except ParseError as e:
112 except ParseError as e:
@@ -273,14 +273,14 b' class Merge3Text(object):'
273 return sl
273 return sl
274
274
275
275
276 def _verifytext(text, path, ui, opts):
276 def _verifytext(text, path, ui, quiet=False, allow_binary=False):
277 """verifies that text is non-binary (unless opts[text] is passed,
277 """verifies that text is non-binary (unless opts[text] is passed,
278 then we just warn)"""
278 then we just warn)"""
279 if stringutil.binary(text):
279 if stringutil.binary(text):
280 msg = _(b"%s looks like a binary file.") % path
280 msg = _(b"%s looks like a binary file.") % path
281 if not opts.get('quiet'):
281 if not quiet:
282 ui.warn(_(b'warning: %s\n') % msg)
282 ui.warn(_(b'warning: %s\n') % msg)
283 if not opts.get('text'):
283 if not allow_binary:
284 raise error.Abort(msg)
284 raise error.Abort(msg)
285 return text
285 return text
286
286
@@ -484,7 +484,16 b' class MergeInput(object):'
484 label_detail = attr.ib(default=None)
484 label_detail = attr.ib(default=None)
485
485
486
486
487 def simplemerge(ui, local, base, other, **opts):
487 def simplemerge(
488 ui,
489 local,
490 base,
491 other,
492 mode=b'merge',
493 quiet=False,
494 allow_binary=False,
495 print_result=False,
496 ):
488 """Performs the simplemerge algorithm.
497 """Performs the simplemerge algorithm.
489
498
490 The merged result is written into `localctx`.
499 The merged result is written into `localctx`.
@@ -498,7 +507,13 b' def simplemerge(ui, local, base, other, '
498 # Maintain that behavior today for BC, though perhaps in the future
507 # Maintain that behavior today for BC, though perhaps in the future
499 # it'd be worth considering whether merging encoded data (what the
508 # it'd be worth considering whether merging encoded data (what the
500 # repository usually sees) might be more useful.
509 # repository usually sees) might be more useful.
501 return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
510 return _verifytext(
511 ctx.decodeddata(),
512 ctx.path(),
513 ui,
514 quiet=quiet,
515 allow_binary=allow_binary,
516 )
502
517
503 try:
518 try:
504 localtext = readctx(local.fctx)
519 localtext = readctx(local.fctx)
@@ -509,7 +524,6 b' def simplemerge(ui, local, base, other, '
509
524
510 m3 = Merge3Text(basetext, localtext, othertext)
525 m3 = Merge3Text(basetext, localtext, othertext)
511 conflicts = False
526 conflicts = False
512 mode = opts.get('mode', b'merge')
513 if mode == b'union':
527 if mode == b'union':
514 lines = _resolve(m3, (1, 2))
528 lines = _resolve(m3, (1, 2))
515 elif mode == b'local':
529 elif mode == b'local':
@@ -528,7 +542,7 b' def simplemerge(ui, local, base, other, '
528 lines, conflicts = render_minimized(m3, *labels)
542 lines, conflicts = render_minimized(m3, *labels)
529
543
530 mergedtext = b''.join(lines)
544 mergedtext = b''.join(lines)
531 if opts.get('print'):
545 if print_result:
532 ui.fout.write(mergedtext)
546 ui.fout.write(mergedtext)
533 else:
547 else:
534 # local.fctx.flags() already has the merged flags (done in
548 # local.fctx.flags() already has the merged flags (done in
General Comments 0
You need to be logged in to leave comments. Login now