changeset 12575:9b3913baba0c stable

patch: upgrade to git patch when removing binary file Otherwise it may cause data loss when removing binary files in mq with --git=auto.
author Patrick Mezard <pmezard@gmail.com>
date Tue, 28 Sep 2010 00:41:07 +0200
parents 77600d697d0e
children 1c9bb7e00f71
files mercurial/patch.py tests/test-diff-upgrade tests/test-diff-upgrade.out
diffstat 3 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Mon Sep 27 22:47:10 2010 +0200
+++ b/mercurial/patch.py	Tue Sep 28 00:41:07 2010 +0200
@@ -1588,7 +1588,7 @@
                     else:
                         header.append('deleted file mode %s\n' %
                                       gitmode[man1.flags(f)])
-                elif not to:
+                elif not to or util.binary(to):
                     # regular diffs cannot represent empty file deletion
                     losedatafn(f)
             else:
--- a/tests/test-diff-upgrade	Mon Sep 27 22:47:10 2010 +0200
+++ b/tests/test-diff-upgrade	Tue Sep 28 00:41:07 2010 +0200
@@ -43,10 +43,10 @@
 echo '% git=no: git diff for single regular file'
 hg autodiff --git=yes regular
 
-echo '% git=auto: regular diff for regular files and removals'
-hg autodiff --git=auto regular newregular rmregular rmbinary rmexec
+echo '% git=auto: regular diff for regular files and non-binary removals'
+hg autodiff --git=auto regular newregular rmregular rmexec
 
-for f in exec newexec setexec unsetexec binary newbinary newempty rmempty; do
+for f in exec newexec setexec unsetexec binary newbinary newempty rmempty rmbinary; do
     echo '% git=auto: git diff for' $f
     hg autodiff --git=auto $f
 done
--- a/tests/test-diff-upgrade.out	Mon Sep 27 22:47:10 2010 +0200
+++ b/tests/test-diff-upgrade.out	Tue Sep 28 00:41:07 2010 +0200
@@ -62,7 +62,7 @@
 @@ -1,1 +1,2 @@
  regular
 +regular
-% git=auto: regular diff for regular files and removals
+% git=auto: regular diff for regular files and non-binary removals
 diff -r b3f053cd7c7f newregular
 --- /dev/null
 +++ b/newregular
@@ -74,8 +74,6 @@
 @@ -1,1 +1,2 @@
  regular
 +regular
-diff -r b3f053cd7c7f rmbinary
-Binary file rmbinary has changed
 diff -r b3f053cd7c7f rmexec
 --- a/rmexec
 +++ /dev/null
@@ -129,6 +127,10 @@
 % git=auto: git diff for rmempty
 diff --git a/rmempty b/rmempty
 deleted file mode 100644
+% git=auto: git diff for rmbinary
+diff --git a/rmbinary b/rmbinary
+deleted file mode 100644
+Binary file rmbinary has changed
 % git=warn: regular diff with data loss warnings
 diff -r b3f053cd7c7f binary
 Binary file binary has changed
@@ -172,6 +174,7 @@
 data lost for: newbinary
 data lost for: newempty
 data lost for: newexec
+data lost for: rmbinary
 data lost for: rmempty
 data lost for: setexec
 data lost for: unsetexec