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