D12144: simplemerge: store file contents in MergeInput type
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Tue Feb 8 21:26:45 UTC 2022
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
I want to be able to update the file contents for support for partial
conflict resolution.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12144
AFFECTED FILES
mercurial/simplemerge.py
CHANGE DETAILS
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -273,18 +273,6 @@
return sl
-def _verifytext(text, path, ui, opts):
- """verifies that text is non-binary (unless opts[text] is passed,
- then we just warn)"""
- if stringutil.binary(text):
- msg = _(b"%s looks like a binary file.") % path
- if not opts.get('quiet'):
- ui.warn(_(b'warning: %s\n') % msg)
- if not opts.get('text'):
- raise error.Abort(msg)
- return text
-
-
def _format_labels(*inputs):
pad = max(len(input.label) if input.label else 0 for input in inputs)
labels = []
@@ -483,6 +471,25 @@
# merge inputs.
label_detail = attr.ib(default=None)
+ def _verifytext(self, ui, opts):
+ """verifies that text is non-binary (unless opts[text] is passed,
+ then we just warn)"""
+ # Merges were always run in the working copy before, which means
+ # they used decoded data, if the user defined any repository
+ # filters.
+ #
+ # Maintain that behavior today for BC, though perhaps in the future
+ # it'd be worth considering whether merging encoded data (what the
+ # repository usually sees) might be more useful.
+ text = self.fctx.decodeddata()
+ if stringutil.binary(text):
+ msg = _(b"%s looks like a binary file.") % self.fctx.path()
+ if not opts.get('quiet'):
+ ui.warn(_(b'warning: %s\n') % msg)
+ if not opts.get('text'):
+ raise error.Abort(msg)
+ return text
+
def simplemerge(ui, local, base, other, **opts):
"""Performs the simplemerge algorithm.
@@ -490,20 +497,10 @@
The merged result is written into `localctx`.
"""
- def readctx(ctx):
- # Merges were always run in the working copy before, which means
- # they used decoded data, if the user defined any repository
- # filters.
- #
- # Maintain that behavior today for BC, though perhaps in the future
- # it'd be worth considering whether merging encoded data (what the
- # repository usually sees) might be more useful.
- return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
-
try:
- localtext = readctx(local.fctx)
- basetext = readctx(base.fctx)
- othertext = readctx(other.fctx)
+ localtext = local._verifytext(ui, opts)
+ basetext = base._verifytext(ui, opts)
+ othertext = other._verifytext(ui, opts)
except error.Abort:
return True
To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list