[PATCH STABLE] simplemerge: do not allow binary files to abort an entire merge
Steve Borho
steve at borho.org
Fri May 13 19:47:10 CDT 2011
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1305333996 18000
# Branch stable
# Node ID 3c65cdcf3ba6cdaa75e7b9e6eb8ef0ff0d3db197
# Parent 2a6ee654655e5eb2f42665d968835c3bc5743037
simplemerge: do not allow binary files to abort an entire merge
When used as the default merge tool, or used as a --tool override,
the simplemerge script should not be allowed to raise a util.Abort
just because one of the files being merged is binary. Instead, return
1 and mark the file unresolved.
diff -r 2a6ee654655e -r 3c65cdcf3ba6 mercurial/simplemerge.py
--- a/mercurial/simplemerge.py Mon May 09 10:46:54 2011 +0200
+++ b/mercurial/simplemerge.py Fri May 13 19:46:36 2011 -0500
@@ -407,10 +407,10 @@
f.close()
if util.binary(text):
msg = _("%s looks like a binary file.") % filename
+ if not opts.get('quiet'):
+ ui.warn(_('warning: %s\n') % msg)
if not opts.get('text'):
raise util.Abort(msg)
- elif not opts.get('quiet'):
- ui.warn(_('warning: %s\n') % msg)
return text
name_a = local
@@ -423,9 +423,12 @@
if labels:
raise util.Abort(_("can only specify two labels."))
- localtext = readfile(local)
- basetext = readfile(base)
- othertext = readfile(other)
+ try:
+ localtext = readfile(local)
+ basetext = readfile(base)
+ othertext = readfile(other)
+ except util.Abort:
+ return 1
local = os.path.realpath(local)
if not opts.get('print'):
diff -r 2a6ee654655e -r 3c65cdcf3ba6 tests/test-simplemerge-cmd.t
--- a/tests/test-simplemerge-cmd.t Mon May 09 10:46:54 2011 +0200
+++ b/tests/test-simplemerge-cmd.t Fri May 13 19:46:36 2011 -0500
@@ -99,8 +99,8 @@
$ python -c "f = file('binary-local', 'w'); f.write('\x00'); f.close()"
$ cat orig >> binary-local
$ python simplemerge -p binary-local base other
- abort: binary-local looks like a binary file.
- [255]
+ warning: binary-local looks like a binary file.
+ [1]
binary file --text
More information about the Mercurial-devel
mailing list