##// 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 13 context,
14 14 error,
15 15 fancyopts,
16 pycompat,
17 16 simplemerge,
18 17 ui as uimod,
19 18 )
@@ -80,8 +79,9 b' try:'
80 79 sys.exit(0)
81 80 if len(args) != 3:
82 81 raise ParseError(_(b'wrong number of arguments').decode('utf8'))
82 mode = b'merge'
83 83 if len(opts[b'label']) > 2:
84 opts[b'mode'] = b'merge3'
84 mode = b'merge3'
85 85 local, base, other = args
86 86 overrides = opts[b'label']
87 87 if len(overrides) > 3:
@@ -103,7 +103,10 b' try:'
103 103 local_input,
104 104 base_input,
105 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 112 except ParseError as e:
@@ -273,14 +273,14 b' class Merge3Text(object):'
273 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 277 """verifies that text is non-binary (unless opts[text] is passed,
278 278 then we just warn)"""
279 279 if stringutil.binary(text):
280 280 msg = _(b"%s looks like a binary file.") % path
281 if not opts.get('quiet'):
281 if not quiet:
282 282 ui.warn(_(b'warning: %s\n') % msg)
283 if not opts.get('text'):
283 if not allow_binary:
284 284 raise error.Abort(msg)
285 285 return text
286 286
@@ -484,7 +484,16 b' class MergeInput(object):'
484 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 497 """Performs the simplemerge algorithm.
489 498
490 499 The merged result is written into `localctx`.
@@ -498,7 +507,13 b' def simplemerge(ui, local, base, other, '
498 507 # Maintain that behavior today for BC, though perhaps in the future
499 508 # it'd be worth considering whether merging encoded data (what the
500 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 518 try:
504 519 localtext = readctx(local.fctx)
@@ -509,7 +524,6 b' def simplemerge(ui, local, base, other, '
509 524
510 525 m3 = Merge3Text(basetext, localtext, othertext)
511 526 conflicts = False
512 mode = opts.get('mode', b'merge')
513 527 if mode == b'union':
514 528 lines = _resolve(m3, (1, 2))
515 529 elif mode == b'local':
@@ -528,7 +542,7 b' def simplemerge(ui, local, base, other, '
528 542 lines, conflicts = render_minimized(m3, *labels)
529 543
530 544 mergedtext = b''.join(lines)
531 if opts.get('print'):
545 if print_result:
532 546 ui.fout.write(mergedtext)
533 547 else:
534 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