changeset 12576:1c9bb7e00f71 stable

patch: test and document a bit binary to regular file upgrade
author Patrick Mezard <pmezard@gmail.com>
date Tue, 28 Sep 2010 00:41:08 +0200
parents 9b3913baba0c
children 05210e955bef f2937d6492c5
files mercurial/patch.py tests/test-diff-upgrade tests/test-diff-upgrade.out
diffstat 3 files changed, 44 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Tue Sep 28 00:41:07 2010 +0200
+++ b/mercurial/patch.py	Tue Sep 28 00:41:08 2010 +0200
@@ -1569,6 +1569,9 @@
                         header.append('new file mode %s\n' % mode)
                     elif ctx2.flags(f):
                         losedatafn(f)
+                # In theory, if tn was copied or renamed we should check
+                # if the source is binary too but the copy record already
+                # forces git mode.
                 if util.binary(tn):
                     if opts.git:
                         dodiff = 'binary'
--- a/tests/test-diff-upgrade	Tue Sep 28 00:41:07 2010 +0200
+++ b/tests/test-diff-upgrade	Tue Sep 28 00:41:08 2010 +0200
@@ -20,6 +20,7 @@
 chmod +x unsetexec
 echo binary > binary
 python -c "file('rmbinary', 'wb').write('\0')"
+python -c "file('bintoregular', 'wb').write('\0')"
 hg ci -Am addfiles
 echo regular >> regular
 echo newregular >> newregular
@@ -28,6 +29,7 @@
 rm rmregular
 echo exec >> exec
 echo newexec > newexec
+echo bintoregular > bintoregular
 chmod +x newexec
 rm rmexec
 chmod +x setexec
@@ -46,7 +48,8 @@
 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 rmbinary; do
+for f in exec newexec setexec unsetexec binary newbinary newempty rmempty \
+    rmbinary bintoregular; do
     echo '% git=auto: git diff for' $f
     hg autodiff --git=auto $f
 done
--- a/tests/test-diff-upgrade.out	Tue Sep 28 00:41:07 2010 +0200
+++ b/tests/test-diff-upgrade.out	Tue Sep 28 00:41:08 2010 +0200
@@ -1,5 +1,6 @@
 % make a combination of new, changed and deleted file
 adding binary
+adding bintoregular
 adding exec
 adding regular
 adding rmbinary
@@ -17,40 +18,42 @@
 removing rmexec
 removing rmregular
 % git=no: regular diff for all files
-diff -r b3f053cd7c7f binary
+diff -r a66d19b9302d binary
 Binary file binary has changed
-diff -r b3f053cd7c7f exec
+diff -r a66d19b9302d bintoregular
+Binary file bintoregular has changed
+diff -r a66d19b9302d exec
 --- a/exec
 +++ b/exec
 @@ -1,1 +1,2 @@
  exec
 +exec
-diff -r b3f053cd7c7f newbinary
+diff -r a66d19b9302d newbinary
 Binary file newbinary has changed
-diff -r b3f053cd7c7f newexec
+diff -r a66d19b9302d newexec
 --- /dev/null
 +++ b/newexec
 @@ -0,0 +1,1 @@
 +newexec
-diff -r b3f053cd7c7f newregular
+diff -r a66d19b9302d newregular
 --- /dev/null
 +++ b/newregular
 @@ -0,0 +1,1 @@
 +newregular
-diff -r b3f053cd7c7f regular
+diff -r a66d19b9302d regular
 --- a/regular
 +++ b/regular
 @@ -1,1 +1,2 @@
  regular
 +regular
-diff -r b3f053cd7c7f rmbinary
+diff -r a66d19b9302d rmbinary
 Binary file rmbinary has changed
-diff -r b3f053cd7c7f rmexec
+diff -r a66d19b9302d rmexec
 --- a/rmexec
 +++ /dev/null
 @@ -1,1 +0,0 @@
 -rmexec
-diff -r b3f053cd7c7f rmregular
+diff -r a66d19b9302d rmregular
 --- a/rmregular
 +++ /dev/null
 @@ -1,1 +0,0 @@
@@ -63,29 +66,29 @@
  regular
 +regular
 % git=auto: regular diff for regular files and non-binary removals
-diff -r b3f053cd7c7f newregular
+diff -r a66d19b9302d newregular
 --- /dev/null
 +++ b/newregular
 @@ -0,0 +1,1 @@
 +newregular
-diff -r b3f053cd7c7f regular
+diff -r a66d19b9302d regular
 --- a/regular
 +++ b/regular
 @@ -1,1 +1,2 @@
  regular
 +regular
-diff -r b3f053cd7c7f rmexec
+diff -r a66d19b9302d rmexec
 --- a/rmexec
 +++ /dev/null
 @@ -1,1 +0,0 @@
 -rmexec
-diff -r b3f053cd7c7f rmregular
+diff -r a66d19b9302d rmregular
 --- a/rmregular
 +++ /dev/null
 @@ -1,1 +0,0 @@
 -rmregular
 % git=auto: git diff for exec
-diff -r b3f053cd7c7f exec
+diff -r a66d19b9302d exec
 --- a/exec
 +++ b/exec
 @@ -1,1 +1,2 @@
@@ -131,46 +134,56 @@
 diff --git a/rmbinary b/rmbinary
 deleted file mode 100644
 Binary file rmbinary has changed
+% git=auto: git diff for bintoregular
+diff --git a/bintoregular b/bintoregular
+index f76dd238ade08917e6712764a16a22005a50573d..9c42f2b6427d8bf034b7bc23986152dc01bfd3ab
+GIT binary patch
+literal 13
+Uc$`bh%qz(+N=+}#Ni5<5043uE82|tP
+
 % git=warn: regular diff with data loss warnings
-diff -r b3f053cd7c7f binary
+diff -r a66d19b9302d binary
 Binary file binary has changed
-diff -r b3f053cd7c7f exec
+diff -r a66d19b9302d bintoregular
+Binary file bintoregular has changed
+diff -r a66d19b9302d exec
 --- a/exec
 +++ b/exec
 @@ -1,1 +1,2 @@
  exec
 +exec
-diff -r b3f053cd7c7f newbinary
+diff -r a66d19b9302d newbinary
 Binary file newbinary has changed
-diff -r b3f053cd7c7f newexec
+diff -r a66d19b9302d newexec
 --- /dev/null
 +++ b/newexec
 @@ -0,0 +1,1 @@
 +newexec
-diff -r b3f053cd7c7f newregular
+diff -r a66d19b9302d newregular
 --- /dev/null
 +++ b/newregular
 @@ -0,0 +1,1 @@
 +newregular
-diff -r b3f053cd7c7f regular
+diff -r a66d19b9302d regular
 --- a/regular
 +++ b/regular
 @@ -1,1 +1,2 @@
  regular
 +regular
-diff -r b3f053cd7c7f rmbinary
+diff -r a66d19b9302d rmbinary
 Binary file rmbinary has changed
-diff -r b3f053cd7c7f rmexec
+diff -r a66d19b9302d rmexec
 --- a/rmexec
 +++ /dev/null
 @@ -1,1 +0,0 @@
 -rmexec
-diff -r b3f053cd7c7f rmregular
+diff -r a66d19b9302d rmregular
 --- a/rmregular
 +++ /dev/null
 @@ -1,1 +0,0 @@
 -rmregular
 data lost for: binary
+data lost for: bintoregular
 data lost for: newbinary
 data lost for: newempty
 data lost for: newexec
@@ -181,7 +194,7 @@
 % git=abort: fail on execute bit change
 abort: losing data for setexec
 % git=abort: succeed on regular file
-diff -r b3f053cd7c7f regular
+diff -r a66d19b9302d regular
 --- a/regular
 +++ b/regular
 @@ -1,1 +1,2 @@