Patchwork diff: add nobinary config to suppress git-style binary diffs

login
register
mail settings
Submitter Stephen Lee
Date June 21, 2014, 6:04 a.m.
Message ID <9cb45c63e3bbd016a00e.1403330692@slee-desktop>
Download mbox | patch
Permalink /patch/5025/
State Accepted
Commit 3fbef7ac26f05bca222e1c99e6469bdb2fd35528
Headers show

Comments

Stephen Lee - June 21, 2014, 6:04 a.m.
# HG changeset patch
# User Stephen Lee <sphen.lee@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
Pierre-Yves David - June 23, 2014, 10:38 a.m.
On 06/20/2014 11:04 PM, Stephen Lee wrote:
> # HG changeset patch
> # User Stephen Lee <sphen.lee@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

Can you elaborate about why someone would want such config option ?
Matt Mackall - June 23, 2014, 8:51 p.m.
On Sat, 2014-06-21 at 16:04 +1000, Stephen Lee wrote:
> # HG changeset patch
> # User Stephen Lee <sphen.lee@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

(This is useful for people who don't want to see useless binary diffs in
hgweb)

Queued for default, thanks.
Stephen Lee - June 25, 2014, 9 a.m.
On 23 Jun 2014 20:38, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:
>
>
>
> On 06/20/2014 11:04 PM, Stephen Lee wrote:
>>
>> # HG changeset patch
>> # User Stephen Lee <sphen.lee@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
>
>
> Can you elaborate about why someone would want such config option ?
>

Looks like this has already been queued, but just to explain.
If you enable git diff for interactive use, you get copy and rename info,
as well as diff's between copied files. But you also get binary diffs.
These are useless for command line and Hgweb viewing, and are often very
large.
This option allows you to disable them.

Steve

Patch

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 ..