Patchwork [stable] : fix binary file removals in git mode.

login
register
mail settings
Submitter Johan Björk
Date March 8, 2013, 11:24 p.m.
Message ID <CAC_K0eotCsAGxDa_sJfvg7QwQCBvbYbmeLAMtCZiFJhg6S4LAA@mail.gmail.com>
Download mbox | patch
Permalink /patch/1086/
State Rejected
Headers show

Comments

Johan Björk - March 8, 2013, 11:24 p.m.
# HG changeset patch
# User Johan Bjork <jbjoerk@gmail.com>
# Date 1362436451 0
# Branch stable
# Node ID d0a224efdd3cfb5e5b54cdb805b92460a40c5f44
# Parent  605c7c94fd70dcdb2ed695e8420e6ddae10a3a5b
diff: fix binary file removals in git mode.

With the previous version, a binary file removal diff generated with
   diff --git a/bintoregular b/bintoregular

Patch

diff --git would not apply with 'git apply' with the error
"
error: removal patch leaves file contents
error: <file>: patch does not apply
"

diff -r 605c7c94fd70 -r d0a224efdd3c mercurial/patch.py
--- a/mercurial/patch.py        Thu Feb 28 21:53:13 2013 -0600
+++ b/mercurial/patch.py        Mon Mar 04 22:34:11 2013 +0000
@@ -1756,6 +1756,8 @@ 
                     else:
                         header.append('deleted file mode %s\n' %
                                       gitmode[man1.flags(f)])
+                        if util.binary(to):
+                            dodiff = 'binary'
                 elif not to or util.binary(to):
                     # regular diffs cannot represent empty file deletion
                     losedatafn(f)
diff -r 605c7c94fd70 -r d0a224efdd3c tests/test-diff-upgrade.t
--- a/tests/test-diff-upgrade.t Thu Feb 28 21:53:13 2013 -0600
+++ b/tests/test-diff-upgrade.t Mon Mar 04 22:34:11 2013 +0000
@@ -200,7 +200,11 @@ 
   % git=auto: git diff for rmbinary
   diff --git a/rmbinary b/rmbinary
   deleted file mode 100644
-  Binary file rmbinary has changed
+  index
f76dd238ade08917e6712764a16a22005a50573d..0000000000000000000000000000000000000000
+  GIT binary patch
+  literal 0
+  Hc$@<O00001
+

   % git=auto: git diff for bintoregular