Mercurial > hg
changeset 48756:86e4b86df932
filemerge: when not keeping premerge, don't write markers to context
When premerge is enabled (as it is for non-binary inputs by default)
and the markers are not kept, we currently still write it to the
output context and then restore the previous content right after. With
the refactoring in the previous patch, we can easily avoid that step
and instead write the output in the opposite case (i.e. when it's
successful or when the markers are supposed to be kept).
Differential Revision: https://phab.mercurial-scm.org/D12149
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 18 Jan 2022 12:57:55 -0800 |
parents | 6ae3c97a0919 |
children | af9f2c64302e |
files | mercurial/filemerge.py |
diffstat | 1 files changed, 5 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/filemerge.py Fri Jan 14 08:17:13 2022 -0800 +++ b/mercurial/filemerge.py Tue Jan 18 12:57:55 2022 -0800 @@ -411,7 +411,7 @@ raise error.Abort(msg) -def _premerge(repo, local, other, base, toolconf, backup): +def _premerge(repo, local, other, base, toolconf): tool, toolpath, binary, symlink, scriptfn = toolconf if symlink or local.fctx.isabsent() or other.fctx.isabsent(): return 1 @@ -445,15 +445,13 @@ 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()) + if not conflicts or premerge in validkeep: + # 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: - # restore from backup and try again - _restorebackup(local.fctx, backup) return 1 # continue merging @@ -879,12 +877,6 @@ } -def _restorebackup(fcd, backup): - # TODO: Add a workingfilectx.write(otherfilectx) path so we can use - # util.copy here instead. - fcd.write(backup.data(), fcd.flags()) - - def _makebackup(repo, ui, wctx, fcd): """Makes and returns a filectx-like object for ``fcd``'s backup file. @@ -1123,7 +1115,6 @@ other, base, toolconf, - backup, ) # we're done if premerge was successful (r is 0) if not r: