[Updated] D12148: simplemerge: move printing of merge result to extension
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Tue Feb 15 12:56:56 UTC 2022
Closed by commit rHG6ae3c97a0919: simplemerge: move printing of merge result to extension (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12148?vs=32165&id=32191
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
@@ -15,6 +15,7 @@
fancyopts,
simplemerge,
ui as uimod,
+ util,
)
from mercurial.utils import procutil, stringutil
@@ -116,18 +117,21 @@
_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:
+ util.writefile(local, 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, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220215/4750437e/attachment-0002.html>
More information about the Mercurial-patches
mailing list