[Updated] [+-- ] D12148: simplemerge: move printing of merge result to extension
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Mon Feb 14 16:28:30 UTC 2022
martinvonz updated this revision to Diff 32165.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12148?vs=32138&id=32165
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
@@ -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
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220214/a2e76f37/attachment-0002.html>
More information about the Mercurial-patches
mailing list