# HG changeset patch # User Alexander Fomin <afo...@fb.com> # Date 1491334100 25200 # Tue Apr 04 12:28:20 2017 -0700 # Node ID 27515c7e38db9d93e18b7df13149da7c0d88eeb2 # Parent 9be2b4ec19e846d2a95fe801ebe76f83fffd1ea9 hg: 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 (issue5510). diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -160,6 +160,7 @@ logopts = [ diffopts = [ ('a', 'text', None, _('treat all files as text')), ('g', 'git', None, _('use git extended diff format')), + ('', 'binary', None, _('generate binary diffs in Git mode (default)')), ('', 'nodates', None, _('omit dates from diff headers')) ] diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2210,7 +2210,9 @@ def difffeatureopts(ui, opts=None, untru '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(**buildopts) diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -216,8 +216,8 @@ Show all commands + options annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos - diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos - export: output, switch-parent, rev, text, git, nodates + diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos + export: output, switch-parent, rev, text, git, binary, nodates forget: include, exclude init: ssh, remotecmd, insecure log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -543,6 +543,7 @@ Test command without options -c --change REV change made by revision -a --text treat all files as text -g --git use git extended diff format + --binary generate binary diffs in Git mode (default) --nodates omit dates from diff headers --noprefix omit a/ and b/ prefixes from filenames -p --show-function show which function each change is in _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel