changeset 21790:3fbef7ac26f0

diff: add nobinary config to suppress git-style binary diffs
author Stephen Lee <sphen.lee@gmail.com>
date Sat, 21 Jun 2014 15:56:49 +1000
parents 15baed3f24ee
children fb16f6da5b3b
files mercurial/mdiff.py mercurial/patch.py tests/test-diff-binary-file.t
diffstat 3 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mdiff.py	Mon Jun 23 13:50:44 2014 -0500
+++ b/mercurial/mdiff.py	Sat Jun 21 15:56:49 2014 +1000
@@ -37,6 +37,7 @@
         'showfunc': False,
         'git': False,
         'nodates': False,
+        'nobinary': False,
         'ignorews': False,
         'ignorewsamount': False,
         'ignoreblanklines': False,
--- a/mercurial/patch.py	Mon Jun 23 13:50:44 2014 -0500
+++ b/mercurial/patch.py	Sat Jun 21 15:56:49 2014 +1000
@@ -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)])
--- a/tests/test-diff-binary-file.t	Mon Jun 23 13:50:44 2014 -0500
+++ b/tests/test-diff-binary-file.t	Sat Jun 21 15:56:49 2014 +1000
@@ -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 ..