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

Johan Björk jbjoerk at gmail.com
Tue Mar 5 08:25:21 CST 2013


# HG changeset patch
# User Johan Bjork <jbjoerk at 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 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
   diff --git a/bintoregular b/bintoregular
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130305/e2870582/attachment.html>


More information about the Mercurial-devel mailing list