[Updated] D12148: simplemerge: move printing of merge result to extension
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Feb 11 02:55:58 UTC 2022
martinvonz edited the summary of this revision.
martinvonz updated this revision to Diff 32138.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12148?vs=32097&id=32138
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12148/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12148
AFFECTED FILES
contrib/simplemerge
mercurial/filemerge.py
mercurial/simplemerge.py
CHANGE DETAILS
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -532,11 +532,4 @@
lines, conflicts = render_minimized(m3, *labels)
mergedtext = b''.join(lines)
- if print_result:
- ui.fout.write(mergedtext)
- else:
- # local.fctx.flags() already has the merged flags (done in
- # mergestate.resolve())
- local.fctx.write(mergedtext, local.fctx.flags())
-
- return conflicts
+ return mergedtext, conflicts
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -442,10 +442,13 @@
stringutil.binary(input.text()) for input in (local, base, other)
):
return 1 # continue merging
- r = simplemerge.simplemerge(
- ui, local, base, other, quiet=True, mode=mode
+ merged_text, conflicts = simplemerge.simplemerge(
+ ui, local, base, other, mode=mode
)
- if not r:
+ # fcd.flags() already has the merged flags (done in
+ # mergestate.resolve())
+ local.fctx.write(merged_text, local.fctx.flags())
+ if not conflicts:
ui.debug(b" premerge successful\n")
return 0
if premerge not in validkeep:
@@ -489,8 +492,14 @@
_verifytext(other, ui)
except error.Abort:
return True, True, False
- r = simplemerge.simplemerge(ui, local, base, other, mode=mode)
- return True, r, False
+ else:
+ merged_text, conflicts = simplemerge.simplemerge(
+ ui, local, base, other, mode=mode
+ )
+ # fcd.flags() already has the merged flags (done in
+ # mergestate.resolve())
+ local.fctx.write(merged_text, local.fctx.flags())
+ return True, conflicts, False
@internaltool(
diff --git a/contrib/simplemerge b/contrib/simplemerge
--- a/contrib/simplemerge
+++ b/contrib/simplemerge
@@ -116,18 +116,22 @@
_verifytext(base_input, ui, quiet=quiet, allow_binary=allow_binary)
_verifytext(other_input, ui, quiet=quiet, allow_binary=allow_binary)
- sys.exit(
- simplemerge.simplemerge(
- ui,
- local_input,
- base_input,
- other_input,
- mode,
- quiet=True,
- allow_binary=allow_binary,
- print_result=opts.get(b'print'),
- )
+ merged_text, conflicts = simplemerge.simplemerge(
+ ui,
+ local_input,
+ base_input,
+ other_input,
+ mode,
+ quiet=True,
+ allow_binary=allow_binary,
+ print_result=opts.get(b'print'),
)
+ if opts.get(b'print'):
+ ui.fout.write(merged_text)
+ else:
+ with open(local, 'wb') as f:
+ f.write(merged_text)
+ sys.exit(1 if conflicts else 0)
except ParseError as e:
e = stringutil.forcebytestr(e)
procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
To: martinvonz, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220211/fb456476/attachment-0002.html>
More information about the Mercurial-patches
mailing list