diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -97,13 +97,18 @@ base_input = simplemerge.MergeInput( context.arbitraryfilectx(base), labels[2] ) + ui = uimod.ui.load() + opts = pycompat.strkwargs(opts) + try: + local_input.verifytext(ui, **opts) + base_input.verifytext(ui, **opts) + other_input.verifytext(ui, **opts) + except error.Abort: + sys.exit(1) + sys.exit( simplemerge.simplemerge( - uimod.ui.load(), - local_input, - base_input, - other_input, - **pycompat.strkwargs(opts) + ui, local_input, base_input, other_input, **opts ) ) except ParseError as e: diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -429,9 +429,14 @@ mode = b'mergediff' elif premerge == b'keep-merge3': mode = b'merge3' - r = simplemerge.simplemerge( - ui, local, base, other, quiet=True, mode=mode - ) + try: + local.verifytext(ui, quiet=True) + base.verifytext(ui, quiet=True) + other.verifytext(ui, quiet=True) + except error.Abort: + r = True + else: + r = simplemerge.simplemerge(ui, local, base, other, mode=mode) if not r: ui.debug(b" premerge successful\n") return 0 @@ -470,7 +475,14 @@ of merge, unless mode equals 'union' which suppresses the markers.""" ui = repo.ui - r = simplemerge.simplemerge(ui, local, base, other, mode=mode) + try: + local.verifytext(ui) + base.verifytext(ui) + other.verifytext(ui) + except error.Abort: + r = True + else: + r = simplemerge.simplemerge(ui, local, base, other, mode=mode) return True, r, False diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py --- a/mercurial/simplemerge.py +++ b/mercurial/simplemerge.py @@ -493,7 +493,6 @@ 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): @@ -502,14 +501,7 @@ The merged result is written into `localctx`. """ - try: - localtext = local.verifytext(ui, **opts) - basetext = base.verifytext(ui, **opts) - othertext = other.verifytext(ui, **opts) - except error.Abort: - return True - - m3 = Merge3Text(basetext, localtext, othertext) + m3 = Merge3Text(base.text(), local.text(), other.text()) conflicts = False mode = opts.get('mode', b'merge') if mode == b'union':