diff mercurial/patch.py @ 31822:fde4822b0102

diff: add --binary option for git mode diffs This patch adds --binary option to `hg diff` and `hg export` to allow more control about when binary diffs are displayed in Git mode as well as some tests to verify it behaves correctly (issue5510).
author Alexander Fomin <afomin@fb.com>
date Wed, 05 Apr 2017 15:31:08 -0700
parents 66a9faadbc83
children 51fdedd29b0a
line wrap: on
line diff
--- a/mercurial/patch.py	Wed Apr 05 15:15:06 2017 -0700
+++ b/mercurial/patch.py	Wed Apr 05 15:31:08 2017 -0700
@@ -2210,7 +2210,9 @@
                                             'ignoreblanklines')
     if formatchanging:
         buildopts['text'] = opts and opts.get('text')
-        buildopts['nobinary'] = get('nobinary', forceplain=False)
+        binary = None if opts is None else opts.get('binary')
+        buildopts['nobinary'] = (not binary if binary is not None
+                                 else get('nobinary', forceplain=False))
         buildopts['noprefix'] = get('noprefix', forceplain=False)
 
     return mdiff.diffopts(**pycompat.strkwargs(buildopts))