##// END OF EJS Templates
simplemerge: move printing of merge result to extension...
Martin von Zweigbergk -
r49599:6ae3c97a default
parent child Browse files
Show More
@@ -15,6 +15,7 b' from mercurial import ('
15 fancyopts,
15 fancyopts,
16 simplemerge,
16 simplemerge,
17 ui as uimod,
17 ui as uimod,
18 util,
18 )
19 )
19 from mercurial.utils import procutil, stringutil
20 from mercurial.utils import procutil, stringutil
20
21
@@ -116,18 +117,21 b' try:'
116 _verifytext(base_input, ui, quiet=quiet, allow_binary=allow_binary)
117 _verifytext(base_input, ui, quiet=quiet, allow_binary=allow_binary)
117 _verifytext(other_input, ui, quiet=quiet, allow_binary=allow_binary)
118 _verifytext(other_input, ui, quiet=quiet, allow_binary=allow_binary)
118
119
119 sys.exit(
120 merged_text, conflicts = simplemerge.simplemerge(
120 simplemerge.simplemerge(
121 ui,
121 ui,
122 local_input,
122 local_input,
123 base_input,
123 base_input,
124 other_input,
124 other_input,
125 mode,
125 mode,
126 quiet=True,
126 quiet=True,
127 allow_binary=allow_binary,
127 allow_binary=allow_binary,
128 print_result=opts.get(b'print'),
128 print_result=opts.get(b'print'),
129 )
130 )
129 )
130 if opts.get(b'print'):
131 ui.fout.write(merged_text)
132 else:
133 util.writefile(local, merged_text)
134 sys.exit(1 if conflicts else 0)
131 except ParseError as e:
135 except ParseError as e:
132 e = stringutil.forcebytestr(e)
136 e = stringutil.forcebytestr(e)
133 procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
137 procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
@@ -442,10 +442,13 b' def _premerge(repo, local, other, base, '
442 stringutil.binary(input.text()) for input in (local, base, other)
442 stringutil.binary(input.text()) for input in (local, base, other)
443 ):
443 ):
444 return 1 # continue merging
444 return 1 # continue merging
445 r = simplemerge.simplemerge(
445 merged_text, conflicts = simplemerge.simplemerge(
446 ui, local, base, other, quiet=True, mode=mode
446 ui, local, base, other, mode=mode
447 )
447 )
448 if not r:
448 # fcd.flags() already has the merged flags (done in
449 # mergestate.resolve())
450 local.fctx.write(merged_text, local.fctx.flags())
451 if not conflicts:
449 ui.debug(b" premerge successful\n")
452 ui.debug(b" premerge successful\n")
450 return 0
453 return 0
451 if premerge not in validkeep:
454 if premerge not in validkeep:
@@ -489,8 +492,14 b' def _merge(repo, local, other, base, mod'
489 _verifytext(other, ui)
492 _verifytext(other, ui)
490 except error.Abort:
493 except error.Abort:
491 return True, True, False
494 return True, True, False
492 r = simplemerge.simplemerge(ui, local, base, other, mode=mode)
495 else:
493 return True, r, False
496 merged_text, conflicts = simplemerge.simplemerge(
497 ui, local, base, other, mode=mode
498 )
499 # fcd.flags() already has the merged flags (done in
500 # mergestate.resolve())
501 local.fctx.write(merged_text, local.fctx.flags())
502 return True, conflicts, False
494
503
495
504
496 @internaltool(
505 @internaltool(
@@ -532,11 +532,4 b' def simplemerge('
532 lines, conflicts = render_minimized(m3, *labels)
532 lines, conflicts = render_minimized(m3, *labels)
533
533
534 mergedtext = b''.join(lines)
534 mergedtext = b''.join(lines)
535 if print_result:
535 return mergedtext, conflicts
536 ui.fout.write(mergedtext)
537 else:
538 # local.fctx.flags() already has the merged flags (done in
539 # mergestate.resolve())
540 local.fctx.write(mergedtext, local.fctx.flags())
541
542 return conflicts
General Comments 0
You need to be logged in to leave comments. Login now