[PATCH] diff: add nobinary config to suppress git-style binary diffs
Stephen Lee
sphen.lee at gmail.com
Sat Jun 21 01:04:52 CDT 2014
# HG changeset patch
# User Stephen Lee <sphen.lee at gmail.com>
# Date 1403330209 -36000
# Sat Jun 21 15:56:49 2014 +1000
# Node ID 9cb45c63e3bbd016a00ea71f132d8e67c7412f9a
# Parent cd3c79392056a0d965236e4986a7a4b5d580f3e5
diff: add nobinary config to suppress git-style binary diffs
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -37,6 +37,7 @@
'showfunc': False,
'git': False,
'nodates': False,
+ 'nobinary': False,
'ignorews': False,
'ignorewsamount': False,
'ignoreblanklines': False,
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1561,6 +1561,7 @@
text=opts and opts.get('text'),
git=get('git'),
nodates=get('nodates'),
+ nobinary=get('nobinary'),
showfunc=get('show_function', 'showfunc'),
ignorews=get('ignore_all_space', 'ignorews'),
ignorewsamount=get('ignore_space_change', 'ignorewsamount'),
@@ -1815,7 +1816,7 @@
if dodiff:
if opts.git or revs:
header.insert(0, diffline(join(a), join(b), revs))
- if dodiff == 'binary':
+ if dodiff == 'binary' and not opts.nobinary:
text = mdiff.b85diff(to, tn)
if text:
addindexmeta(header, [gitindex(to), gitindex(tn)])
diff --git a/tests/test-diff-binary-file.t b/tests/test-diff-binary-file.t
--- a/tests/test-diff-binary-file.t
+++ b/tests/test-diff-binary-file.t
@@ -37,4 +37,8 @@
$ hg diff --git -r 0 -r 2
+ $ hg diff --config diff.nobinary=True --git -r 0 -r 1
+ diff --git a/binfile.bin b/binfile.bin
+ Binary file binfile.bin has changed
+
$ cd ..
More information about the Mercurial-devel
mailing list