Show More
@@ -1184,7 +1184,9 b' def _applydiff(ui, fp, patcher, copyfn, ' | |||
|
1184 | 1184 | gp.path = pathstrip(gp.path, strip - 1)[1] |
|
1185 | 1185 | if gp.oldpath: |
|
1186 | 1186 | gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1] |
|
1187 | if gp.op in ('COPY', 'RENAME'): | |
|
1187 | # Binary patches really overwrite target files, copying them | |
|
1188 | # will just make it fails with "target file exists" | |
|
1189 | if gp.op in ('COPY', 'RENAME') and not gp.binary: | |
|
1188 | 1190 | copyfn(gp.oldpath, gp.path, cwd) |
|
1189 | 1191 | changed[gp.path] = gp |
|
1190 | 1192 | else: |
@@ -1530,6 +1532,9 b' def trydiff(repo, revs, ctx1, ctx2, modi' | |||
|
1530 | 1532 | header.append('new file mode %s\n' % mode) |
|
1531 | 1533 | elif ctx2.flags(f): |
|
1532 | 1534 | losedatafn(f) |
|
1535 | # In theory, if tn was copied or renamed we should check | |
|
1536 | # if the source is binary too but the copy record already | |
|
1537 | # forces git mode. | |
|
1533 | 1538 | if util.binary(tn): |
|
1534 | 1539 | if opts.git: |
|
1535 | 1540 | dodiff = 'binary' |
@@ -1549,7 +1554,7 b' def trydiff(repo, revs, ctx1, ctx2, modi' | |||
|
1549 | 1554 | else: |
|
1550 | 1555 | header.append('deleted file mode %s\n' % |
|
1551 | 1556 | gitmode[man1.flags(f)]) |
|
1552 | elif not to: | |
|
1557 | elif not to or util.binary(to): | |
|
1553 | 1558 | # regular diffs cannot represent empty file deletion |
|
1554 | 1559 | losedatafn(f) |
|
1555 | 1560 | else: |
@@ -7,10 +7,13 b'' | |||
|
7 | 7 | $ hg init repo |
|
8 | 8 | $ cd repo |
|
9 | 9 | |
|
10 | ||
|
11 | ||
|
10 | 12 | make a combination of new, changed and deleted file |
|
11 | 13 | |
|
12 | 14 | $ echo regular > regular |
|
13 | 15 | $ echo rmregular > rmregular |
|
16 | $ python -c "file('bintoregular', 'wb').write('\0')" | |
|
14 | 17 | $ touch rmempty |
|
15 | 18 | $ echo exec > exec |
|
16 | 19 | $ chmod +x exec |
@@ -23,6 +26,7 b' make a combination of new, changed and d' | |||
|
23 | 26 | $ python -c "file('rmbinary', 'wb').write('\0')" |
|
24 | 27 | $ hg ci -Am addfiles |
|
25 | 28 | adding binary |
|
29 | adding bintoregular | |
|
26 | 30 | adding exec |
|
27 | 31 | adding regular |
|
28 | 32 | adding rmbinary |
@@ -38,6 +42,7 b' make a combination of new, changed and d' | |||
|
38 | 42 | $ rm rmregular |
|
39 | 43 | $ echo exec >> exec |
|
40 | 44 | $ echo newexec > newexec |
|
45 | $ echo bintoregular > bintoregular | |
|
41 | 46 | $ chmod +x newexec |
|
42 | 47 | $ rm rmexec |
|
43 | 48 | $ chmod +x setexec |
@@ -58,40 +63,42 b' make a combination of new, changed and d' | |||
|
58 | 63 | git=no: regular diff for all files |
|
59 | 64 | |
|
60 | 65 | $ hg autodiff --git=no |
|
61 |
diff -r |
|
|
66 | diff -r a66d19b9302d binary | |
|
62 | 67 | Binary file binary has changed |
|
63 | diff -r b3f053cd7c7f exec | |
|
68 | diff -r a66d19b9302d bintoregular | |
|
69 | Binary file bintoregular has changed | |
|
70 | diff -r a66d19b9302d exec | |
|
64 | 71 | --- a/exec |
|
65 | 72 | +++ b/exec |
|
66 | 73 | @@ -1,1 +1,2 @@ |
|
67 | 74 | exec |
|
68 | 75 | +exec |
|
69 |
diff -r |
|
|
76 | diff -r a66d19b9302d newbinary | |
|
70 | 77 | Binary file newbinary has changed |
|
71 |
diff -r |
|
|
78 | diff -r a66d19b9302d newexec | |
|
72 | 79 | --- /dev/null |
|
73 | 80 | +++ b/newexec |
|
74 | 81 | @@ -0,0 +1,1 @@ |
|
75 | 82 | +newexec |
|
76 |
diff -r |
|
|
83 | diff -r a66d19b9302d newregular | |
|
77 | 84 | --- /dev/null |
|
78 | 85 | +++ b/newregular |
|
79 | 86 | @@ -0,0 +1,1 @@ |
|
80 | 87 | +newregular |
|
81 |
diff -r |
|
|
88 | diff -r a66d19b9302d regular | |
|
82 | 89 | --- a/regular |
|
83 | 90 | +++ b/regular |
|
84 | 91 | @@ -1,1 +1,2 @@ |
|
85 | 92 | regular |
|
86 | 93 | +regular |
|
87 |
diff -r |
|
|
94 | diff -r a66d19b9302d rmbinary | |
|
88 | 95 | Binary file rmbinary has changed |
|
89 |
diff -r |
|
|
96 | diff -r a66d19b9302d rmexec | |
|
90 | 97 | --- a/rmexec |
|
91 | 98 | +++ /dev/null |
|
92 | 99 | @@ -1,1 +0,0 @@ |
|
93 | 100 | -rmexec |
|
94 |
diff -r |
|
|
101 | diff -r a66d19b9302d rmregular | |
|
95 | 102 | --- a/rmregular |
|
96 | 103 | +++ /dev/null |
|
97 | 104 | @@ -1,1 +0,0 @@ |
@@ -107,41 +114,39 b' git=yes: git diff for single regular fil' | |||
|
107 | 114 | regular |
|
108 | 115 | +regular |
|
109 | 116 | |
|
110 | git=auto: regular diff for regular files and removals | |
|
117 | git=auto: regular diff for regular files and non-binary removals | |
|
111 | 118 | |
|
112 |
$ hg autodiff --git=auto regular newregular rmregular |
|
|
113 |
diff -r |
|
|
119 | $ hg autodiff --git=auto regular newregular rmregular rmexec | |
|
120 | diff -r a66d19b9302d newregular | |
|
114 | 121 | --- /dev/null |
|
115 | 122 | +++ b/newregular |
|
116 | 123 | @@ -0,0 +1,1 @@ |
|
117 | 124 | +newregular |
|
118 |
diff -r |
|
|
125 | diff -r a66d19b9302d regular | |
|
119 | 126 | --- a/regular |
|
120 | 127 | +++ b/regular |
|
121 | 128 | @@ -1,1 +1,2 @@ |
|
122 | 129 | regular |
|
123 | 130 | +regular |
|
124 | diff -r b3f053cd7c7f rmbinary | |
|
125 | Binary file rmbinary has changed | |
|
126 | diff -r b3f053cd7c7f rmexec | |
|
131 | diff -r a66d19b9302d rmexec | |
|
127 | 132 | --- a/rmexec |
|
128 | 133 | +++ /dev/null |
|
129 | 134 | @@ -1,1 +0,0 @@ |
|
130 | 135 | -rmexec |
|
131 |
diff -r |
|
|
136 | diff -r a66d19b9302d rmregular | |
|
132 | 137 | --- a/rmregular |
|
133 | 138 | +++ /dev/null |
|
134 | 139 | @@ -1,1 +0,0 @@ |
|
135 | 140 | -rmregular |
|
136 | 141 | |
|
137 | $ for f in exec newexec setexec unsetexec binary newbinary newempty rmempty; do | |
|
142 | $ for f in exec newexec setexec unsetexec binary newbinary newempty rmempty rmbinary bintoregular; do | |
|
138 | 143 | > echo |
|
139 | 144 | > echo '% git=auto: git diff for' $f |
|
140 | 145 | > hg autodiff --git=auto $f |
|
141 | 146 | > done |
|
142 | 147 | |
|
143 | 148 | % git=auto: git diff for exec |
|
144 |
diff -r |
|
|
149 | diff -r a66d19b9302d exec | |
|
145 | 150 | --- a/exec |
|
146 | 151 | +++ b/exec |
|
147 | 152 | @@ -1,1 +1,2 @@ |
@@ -191,51 +196,68 b' git=auto: regular diff for regular files' | |||
|
191 | 196 | diff --git a/rmempty b/rmempty |
|
192 | 197 | deleted file mode 100644 |
|
193 | 198 | |
|
199 | % git=auto: git diff for rmbinary | |
|
200 | diff --git a/rmbinary b/rmbinary | |
|
201 | deleted file mode 100644 | |
|
202 | Binary file rmbinary has changed | |
|
203 | ||
|
204 | % git=auto: git diff for bintoregular | |
|
205 | diff --git a/bintoregular b/bintoregular | |
|
206 | index f76dd238ade08917e6712764a16a22005a50573d..9c42f2b6427d8bf034b7bc23986152dc01bfd3ab | |
|
207 | GIT binary patch | |
|
208 | literal 13 | |
|
209 | Uc$`bh%qz(+N=+}#Ni5<5043uE82|tP | |
|
210 | ||
|
211 | ||
|
194 | 212 | git=warn: regular diff with data loss warnings |
|
195 | 213 | |
|
196 | 214 | $ hg autodiff --git=warn |
|
197 |
diff -r |
|
|
215 | diff -r a66d19b9302d binary | |
|
198 | 216 | Binary file binary has changed |
|
199 | diff -r b3f053cd7c7f exec | |
|
217 | diff -r a66d19b9302d bintoregular | |
|
218 | Binary file bintoregular has changed | |
|
219 | diff -r a66d19b9302d exec | |
|
200 | 220 | --- a/exec |
|
201 | 221 | +++ b/exec |
|
202 | 222 | @@ -1,1 +1,2 @@ |
|
203 | 223 | exec |
|
204 | 224 | +exec |
|
205 |
diff -r |
|
|
225 | diff -r a66d19b9302d newbinary | |
|
206 | 226 | Binary file newbinary has changed |
|
207 |
diff -r |
|
|
227 | diff -r a66d19b9302d newexec | |
|
208 | 228 | --- /dev/null |
|
209 | 229 | +++ b/newexec |
|
210 | 230 | @@ -0,0 +1,1 @@ |
|
211 | 231 | +newexec |
|
212 |
diff -r |
|
|
232 | diff -r a66d19b9302d newregular | |
|
213 | 233 | --- /dev/null |
|
214 | 234 | +++ b/newregular |
|
215 | 235 | @@ -0,0 +1,1 @@ |
|
216 | 236 | +newregular |
|
217 |
diff -r |
|
|
237 | diff -r a66d19b9302d regular | |
|
218 | 238 | --- a/regular |
|
219 | 239 | +++ b/regular |
|
220 | 240 | @@ -1,1 +1,2 @@ |
|
221 | 241 | regular |
|
222 | 242 | +regular |
|
223 |
diff -r |
|
|
243 | diff -r a66d19b9302d rmbinary | |
|
224 | 244 | Binary file rmbinary has changed |
|
225 |
diff -r |
|
|
245 | diff -r a66d19b9302d rmexec | |
|
226 | 246 | --- a/rmexec |
|
227 | 247 | +++ /dev/null |
|
228 | 248 | @@ -1,1 +0,0 @@ |
|
229 | 249 | -rmexec |
|
230 |
diff -r |
|
|
250 | diff -r a66d19b9302d rmregular | |
|
231 | 251 | --- a/rmregular |
|
232 | 252 | +++ /dev/null |
|
233 | 253 | @@ -1,1 +0,0 @@ |
|
234 | 254 | -rmregular |
|
235 | 255 | data lost for: binary |
|
256 | data lost for: bintoregular | |
|
236 | 257 | data lost for: newbinary |
|
237 | 258 | data lost for: newempty |
|
238 | 259 | data lost for: newexec |
|
260 | data lost for: rmbinary | |
|
239 | 261 | data lost for: rmempty |
|
240 | 262 | data lost for: setexec |
|
241 | 263 | data lost for: unsetexec |
@@ -249,7 +271,7 b' git=abort: fail on execute bit change' | |||
|
249 | 271 | git=abort: succeed on regular file |
|
250 | 272 | |
|
251 | 273 | $ hg autodiff --git=abort regular |
|
252 |
diff -r |
|
|
274 | diff -r a66d19b9302d regular | |
|
253 | 275 | --- a/regular |
|
254 | 276 | +++ b/regular |
|
255 | 277 | @@ -1,1 +1,2 @@ |
@@ -335,3 +335,24 b' Copy then modify the original file:' | |||
|
335 | 335 | $ cat foo3 |
|
336 | 336 | foo |
|
337 | 337 | |
|
338 | Move text file and patch as binary | |
|
339 | ||
|
340 | $ echo a > text2 | |
|
341 | $ hg ci -Am0 | |
|
342 | adding text2 | |
|
343 | $ hg import -d "1000000 0" -m rename-as-binary - <<"EOF" | |
|
344 | > diff --git a/text2 b/binary2 | |
|
345 | > rename from text2 | |
|
346 | > rename to binary2 | |
|
347 | > index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757 | |
|
348 | > GIT binary patch | |
|
349 | > literal 5 | |
|
350 | > Mc$`b*O5$Pw00T?_*Z=?k | |
|
351 | > | |
|
352 | > EOF | |
|
353 | applying patch from stdin | |
|
354 | $ python $TESTDIR/printrepr.py < binary2 | |
|
355 | a | |
|
356 | b | |
|
357 | \x00 | |
|
358 | $ hg st --copies --change . abort: unknown revision '.echo'! |
General Comments 0
You need to be logged in to leave comments.
Login now