[PATCH 5 of 7] patch: require text mode (-a) for binary patches in git mode (issue5510) (BC)

Alexander Fomin afomin at fb.com
Tue Mar 21 13:08:38 EDT 2017


# HG changeset patch
# User Alexander Fomin <afomin at fb.com>
# Date 1490105843 25200
#      Tue Mar 21 07:17:23 2017 -0700
# Node ID 98301edf86daecef6ef43357b0934c351f58574d
# Parent  b1eb6801f90a45ef43f17a22d9835ccba4ac190b
patch: require text mode (-a) for binary patches in git mode (issue5510) (BC)

This changeset makes patch explicitly request binary diffs generation by using
-a/--text option even when in Git mode.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2358,7 +2358,8 @@ def diffhunks(repo, node1=None, node2=No
             # Buffer the whole output until we are sure it can be generated
             return list(difffn(opts.copy(git=False), losedata))
         except GitDiffRequired:
-            return difffn(opts.copy(git=True), None)
+            # Explicitly request binary diffs if Git mode is required
+            return difffn(opts.copy(git=True, text=True), None)
     else:
         return difffn(opts, None)
 
@@ -2552,7 +2553,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi
         elif revs and not repo.ui.quiet:
             header.append(diffline(path1, revs))
 
-        if binary and opts.git and not opts.nobinary:
+        if binary and opts.git and opts.text and not opts.nobinary:
             text = mdiff.b85diff(content1, content2)
             if text:
                 header.append('index %s..%s' %


More information about the Mercurial-devel mailing list