##// END OF EJS Templates
simplemerge: work with opts as native strings instead of bytes...
Martin von Zweigbergk -
r46714:5510e2ac default
parent child Browse files
Show More
@@ -433,9 +433,9 b' def _verifytext(text, path, ui, opts):'
433 then we just warn)"""
433 then we just warn)"""
434 if stringutil.binary(text):
434 if stringutil.binary(text):
435 msg = _(b"%s looks like a binary file.") % path
435 msg = _(b"%s looks like a binary file.") % path
436 if not opts.get(b'quiet'):
436 if not opts.get('quiet'):
437 ui.warn(_(b'warning: %s\n') % msg)
437 ui.warn(_(b'warning: %s\n') % msg)
438 if not opts.get(b'text'):
438 if not opts.get('text'):
439 raise error.Abort(msg)
439 raise error.Abort(msg)
440 return text
440 return text
441
441
@@ -460,7 +460,6 b' def simplemerge(ui, localctx, basectx, o'
460
460
461 The merged result is written into `localctx`.
461 The merged result is written into `localctx`.
462 """
462 """
463 opts = pycompat.byteskwargs(opts)
464
463
465 def readctx(ctx):
464 def readctx(ctx):
466 # Merges were always run in the working copy before, which means
465 # Merges were always run in the working copy before, which means
@@ -472,11 +471,11 b' def simplemerge(ui, localctx, basectx, o'
472 # repository usually sees) might be more useful.
471 # repository usually sees) might be more useful.
473 return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
472 return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
474
473
475 mode = opts.get(b'mode', b'merge')
474 mode = opts.get('mode', b'merge')
476 name_a, name_b, name_base = None, None, None
475 name_a, name_b, name_base = None, None, None
477 if mode != b'union':
476 if mode != b'union':
478 name_a, name_b, name_base = _picklabels(
477 name_a, name_b, name_base = _picklabels(
479 [localctx.path(), otherctx.path(), None], opts.get(b'label', [])
478 [localctx.path(), otherctx.path(), None], opts.get('label', [])
480 )
479 )
481
480
482 try:
481 try:
@@ -488,7 +487,7 b' def simplemerge(ui, localctx, basectx, o'
488
487
489 m3 = Merge3Text(basetext, localtext, othertext)
488 m3 = Merge3Text(basetext, localtext, othertext)
490 extrakwargs = {
489 extrakwargs = {
491 b"localorother": opts.get(b"localorother", None),
490 b"localorother": opts.get("localorother", None),
492 b'minimize': True,
491 b'minimize': True,
493 }
492 }
494 if mode == b'union':
493 if mode == b'union':
@@ -504,7 +503,7 b' def simplemerge(ui, localctx, basectx, o'
504 for line in m3.merge_lines(
503 for line in m3.merge_lines(
505 name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs)
504 name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs)
506 ):
505 ):
507 if opts.get(b'print'):
506 if opts.get('print'):
508 ui.fout.write(line)
507 ui.fout.write(line)
509 else:
508 else:
510 mergedtext += line
509 mergedtext += line
@@ -519,7 +518,7 b' def simplemerge(ui, localctx, basectx, o'
519 addedflags = (localflags ^ otherflags) - baseflags
518 addedflags = (localflags ^ otherflags) - baseflags
520 flags = b''.join(sorted(commonflags | addedflags))
519 flags = b''.join(sorted(commonflags | addedflags))
521
520
522 if not opts.get(b'print'):
521 if not opts.get('print'):
523 localctx.write(mergedtext, flags)
522 localctx.write(mergedtext, flags)
524
523
525 if m3.conflicts and not mode == b'union':
524 if m3.conflicts and not mode == b'union':
General Comments 0
You need to be logged in to leave comments. Login now