##// END OF EJS Templates
tests: add a test to demonstrate a bug in `hg diff --git` (issue6486)...
Sushil khanchi -
r47278:df44bac9 stable
parent child Browse files
Show More
@@ -1,458 +1,481 b''
1 1 $ hg init repo
2 2 $ cd repo
3 3 $ cat > a <<EOF
4 4 > c
5 5 > c
6 6 > a
7 7 > a
8 8 > b
9 9 > a
10 10 > a
11 11 > c
12 12 > c
13 13 > EOF
14 14 $ hg ci -Am adda
15 15 adding a
16 16
17 17 $ cat > a <<EOF
18 18 > c
19 19 > c
20 20 > a
21 21 > a
22 22 > dd
23 23 > a
24 24 > a
25 25 > c
26 26 > c
27 27 > EOF
28 28
29 29 default context
30 30
31 31 $ hg diff --nodates
32 32 diff -r cf9f4ba66af2 a
33 33 --- a/a
34 34 +++ b/a
35 35 @@ -2,7 +2,7 @@
36 36 c
37 37 a
38 38 a
39 39 -b
40 40 +dd
41 41 a
42 42 a
43 43 c
44 44
45 45 invalid --unified
46 46
47 47 $ hg diff --nodates -U foo
48 48 abort: diff context lines count must be an integer, not 'foo'
49 49 [255]
50 50
51 51
52 52 $ hg diff --nodates -U 2
53 53 diff -r cf9f4ba66af2 a
54 54 --- a/a
55 55 +++ b/a
56 56 @@ -3,5 +3,5 @@
57 57 a
58 58 a
59 59 -b
60 60 +dd
61 61 a
62 62 a
63 63
64 64 $ hg --config diff.unified=2 diff --nodates
65 65 diff -r cf9f4ba66af2 a
66 66 --- a/a
67 67 +++ b/a
68 68 @@ -3,5 +3,5 @@
69 69 a
70 70 a
71 71 -b
72 72 +dd
73 73 a
74 74 a
75 75
76 76 $ hg diff --nodates -U 1
77 77 diff -r cf9f4ba66af2 a
78 78 --- a/a
79 79 +++ b/a
80 80 @@ -4,3 +4,3 @@
81 81 a
82 82 -b
83 83 +dd
84 84 a
85 85
86 86 invalid diff.unified
87 87
88 88 $ hg --config diff.unified=foo diff --nodates
89 89 abort: diff context lines count must be an integer, not 'foo'
90 90 [255]
91 91
92 92 noprefix config and option
93 93
94 94 $ hg --config diff.noprefix=True diff --nodates
95 95 diff -r cf9f4ba66af2 a
96 96 --- a
97 97 +++ a
98 98 @@ -2,7 +2,7 @@
99 99 c
100 100 a
101 101 a
102 102 -b
103 103 +dd
104 104 a
105 105 a
106 106 c
107 107 $ hg diff --noprefix --nodates
108 108 diff -r cf9f4ba66af2 a
109 109 --- a
110 110 +++ a
111 111 @@ -2,7 +2,7 @@
112 112 c
113 113 a
114 114 a
115 115 -b
116 116 +dd
117 117 a
118 118 a
119 119 c
120 120
121 121 noprefix config disabled in plain mode, but option still enabled
122 122
123 123 $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
124 124 diff -r cf9f4ba66af2 a
125 125 --- a/a
126 126 +++ b/a
127 127 @@ -2,7 +2,7 @@
128 128 c
129 129 a
130 130 a
131 131 -b
132 132 +dd
133 133 a
134 134 a
135 135 c
136 136 $ HGPLAIN=1 hg diff --noprefix --nodates
137 137 diff -r cf9f4ba66af2 a
138 138 --- a
139 139 +++ a
140 140 @@ -2,7 +2,7 @@
141 141 c
142 142 a
143 143 a
144 144 -b
145 145 +dd
146 146 a
147 147 a
148 148 c
149 149
150 150 $ cd ..
151 151
152 152
153 153 0 lines of context hunk header matches gnu diff hunk header
154 154
155 155 $ hg init diffzero
156 156 $ cd diffzero
157 157 $ cat > f1 << EOF
158 158 > c2
159 159 > c4
160 160 > c5
161 161 > EOF
162 162 $ hg commit -Am0
163 163 adding f1
164 164
165 165 $ cat > f2 << EOF
166 166 > c1
167 167 > c2
168 168 > c3
169 169 > c4
170 170 > EOF
171 171 $ mv f2 f1
172 172 $ hg diff -U0 --nodates
173 173 diff -r 55d8ff78db23 f1
174 174 --- a/f1
175 175 +++ b/f1
176 176 @@ -0,0 +1,1 @@
177 177 +c1
178 178 @@ -1,0 +3,1 @@
179 179 +c3
180 180 @@ -3,1 +4,0 @@
181 181 -c5
182 182
183 183 $ hg diff -U0 --nodates --git
184 184 diff --git a/f1 b/f1
185 185 --- a/f1
186 186 +++ b/f1
187 187 @@ -0,0 +1,1 @@
188 188 +c1
189 189 @@ -1,0 +3,1 @@
190 190 +c3
191 191 @@ -3,1 +4,0 @@
192 192 -c5
193 193
194 194 $ hg diff -U0 --nodates -p
195 195 diff -r 55d8ff78db23 f1
196 196 --- a/f1
197 197 +++ b/f1
198 198 @@ -0,0 +1,1 @@
199 199 +c1
200 200 @@ -1,0 +3,1 @@ c2
201 201 +c3
202 202 @@ -3,1 +4,0 @@ c4
203 203 -c5
204 204
205 205 $ echo a > f1
206 206 $ hg ci -m movef2
207 207
208 208 Test diff headers terminating with TAB when necessary (issue3357)
209 209 Regular diff --nodates, file creation
210 210
211 211 $ hg mv f1 'f 1'
212 212 $ echo b > 'f 1'
213 213 $ hg diff --nodates 'f 1'
214 214 diff -r 7574207d0d15 f 1
215 215 --- /dev/null
216 216 +++ b/f 1
217 217 @@ -0,0 +1,1 @@
218 218 +b
219 219
220 220 Git diff, adding space
221 221
222 222 $ hg diff --git
223 223 diff --git a/f1 b/f 1
224 224 rename from f1
225 225 rename to f 1
226 226 --- a/f1
227 227 +++ b/f 1
228 228 @@ -1,1 +1,1 @@
229 229 -a
230 230 +b
231 231
232 232 Git diff, adding extended headers
233 233
234 234 $ hg diff --git --config experimental.extendedheader.index=7 --config experimental.extendedheader.similarity=True
235 235 diff --git a/f1 b/f 1
236 236 similarity index 0%
237 237 rename from f1
238 238 rename to f 1
239 239 index 7898192..6178079 100644
240 240 --- a/f1
241 241 +++ b/f 1
242 242 @@ -1,1 +1,1 @@
243 243 -a
244 244 +b
245 245
246 246 $ hg diff --git --config experimental.extendedheader.index=-1
247 247 invalid length for extendedheader.index: '-1'
248 248 diff --git a/f1 b/f 1
249 249 rename from f1
250 250 rename to f 1
251 251 --- a/f1
252 252 +++ b/f 1
253 253 @@ -1,1 +1,1 @@
254 254 -a
255 255 +b
256 256
257 257 $ hg diff --git --config experimental.extendedheader.index=whatever
258 258 invalid value for extendedheader.index: 'whatever'
259 259 diff --git a/f1 b/f 1
260 260 rename from f1
261 261 rename to f 1
262 262 --- a/f1
263 263 +++ b/f 1
264 264 @@ -1,1 +1,1 @@
265 265 -a
266 266 +b
267 267
268 268 Git diff with noprefix
269 269
270 270 $ hg --config diff.noprefix=True diff --git --nodates
271 271 diff --git f1 f 1
272 272 rename from f1
273 273 rename to f 1
274 274 --- f1
275 275 +++ f 1
276 276 @@ -1,1 +1,1 @@
277 277 -a
278 278 +b
279 279
280 280 noprefix config disabled in plain mode, but option still enabled
281 281
282 282 $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
283 283 diff --git a/f1 b/f 1
284 284 rename from f1
285 285 rename to f 1
286 286 --- a/f1
287 287 +++ b/f 1
288 288 @@ -1,1 +1,1 @@
289 289 -a
290 290 +b
291 291 $ HGPLAIN=1 hg diff --git --noprefix --nodates
292 292 diff --git f1 f 1
293 293 rename from f1
294 294 rename to f 1
295 295 --- f1
296 296 +++ f 1
297 297 @@ -1,1 +1,1 @@
298 298 -a
299 299 +b
300 300
301 301 Regular diff --nodates, file deletion
302 302
303 303 $ hg ci -m addspace
304 304 $ hg mv 'f 1' f1
305 305 $ echo a > f1
306 306 $ hg diff --nodates 'f 1'
307 307 diff -r ca50fe67c9c7 f 1
308 308 --- a/f 1
309 309 +++ /dev/null
310 310 @@ -1,1 +0,0 @@
311 311 -b
312 312
313 313 Git diff, removing space
314 314
315 315 $ hg diff --git
316 316 diff --git a/f 1 b/f1
317 317 rename from f 1
318 318 rename to f1
319 319 --- a/f 1
320 320 +++ b/f1
321 321 @@ -1,1 +1,1 @@
322 322 -b
323 323 +a
324 324
325 325 showfunc diff
326 326 $ cat > f1 << EOF
327 327 > int main() {
328 328 > int a = 0;
329 329 > int b = 1;
330 330 > int c = 2;
331 331 > int d = 3;
332 332 > return a + b + c + d;
333 333 > }
334 334 > EOF
335 335 $ hg commit -m addfunction
336 336 $ cat > f1 << EOF
337 337 > int main() {
338 338 > int a = 0;
339 339 > int b = 1;
340 340 > int c = 2;
341 341 > int e = 3;
342 342 > return a + b + c + e;
343 343 > }
344 344 > EOF
345 345 $ hg diff --git
346 346 diff --git a/f1 b/f1
347 347 --- a/f1
348 348 +++ b/f1
349 349 @@ -2,6 +2,6 @@
350 350 int a = 0;
351 351 int b = 1;
352 352 int c = 2;
353 353 - int d = 3;
354 354 - return a + b + c + d;
355 355 + int e = 3;
356 356 + return a + b + c + e;
357 357 }
358 358 $ hg diff --config diff.showfunc=True --git
359 359 diff --git a/f1 b/f1
360 360 --- a/f1
361 361 +++ b/f1
362 362 @@ -2,6 +2,6 @@ int main() {
363 363 int a = 0;
364 364 int b = 1;
365 365 int c = 2;
366 366 - int d = 3;
367 367 - return a + b + c + d;
368 368 + int e = 3;
369 369 + return a + b + c + e;
370 370 }
371 371
372 372 If [diff] git is set to true, but the user says --no-git, we should
373 373 *not* get git diffs
374 374 $ hg diff --nodates --config diff.git=1 --no-git
375 375 diff -r f2c7c817fa55 f1
376 376 --- a/f1
377 377 +++ b/f1
378 378 @@ -2,6 +2,6 @@
379 379 int a = 0;
380 380 int b = 1;
381 381 int c = 2;
382 382 - int d = 3;
383 383 - return a + b + c + d;
384 384 + int e = 3;
385 385 + return a + b + c + e;
386 386 }
387 387
388 388 $ cd ..
389 389
390 390 Long function names should be abbreviated, but multi-byte character shouldn't
391 391 be broken up
392 392
393 393 $ hg init longfunc
394 394 $ cd longfunc
395 395
396 396 >>> with open('a', 'wb') as f:
397 397 ... f.write(b'a' * 39 + b'bb' + b'\n') and None
398 398 ... f.write(b' .\n' * 3) and None
399 399 ... f.write(b' 0 b\n') and None
400 400 ... f.write(b' .\n' * 3) and None
401 401 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None
402 402 ... f.write(b' .\n' * 3) and None
403 403 ... f.write(b' 0 a with grave (single code point)\n') and None
404 404 ... f.write(b' .\n' * 3) and None
405 405 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None
406 406 ... f.write(b' .\n' * 3) and None
407 407 ... f.write(b' 0 a with grave (composition)\n') and None
408 408 ... f.write(b' .\n' * 3) and None
409 409 $ hg ci -qAm0
410 410
411 411 >>> with open('a', 'wb') as f:
412 412 ... f.write(b'a' * 39 + b'bb' + b'\n') and None
413 413 ... f.write(b' .\n' * 3) and None
414 414 ... f.write(b' 1 b\n') and None
415 415 ... f.write(b' .\n' * 3) and None
416 416 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None
417 417 ... f.write(b' .\n' * 3) and None
418 418 ... f.write(b' 1 a with grave (single code point)\n') and None
419 419 ... f.write(b' .\n' * 3) and None
420 420 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None
421 421 ... f.write(b' .\n' * 3) and None
422 422 ... f.write(b' 1 a with grave (composition)\n') and None
423 423 ... f.write(b' .\n' * 3) and None
424 424 $ hg ci -m1
425 425
426 426 $ hg diff -c1 --nodates --show-function
427 427 diff -r 3e92dd6fa812 -r a256341606cb a
428 428 --- a/a
429 429 +++ b/a
430 430 @@ -2,7 +2,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
431 431 .
432 432 .
433 433 .
434 434 - 0 b
435 435 + 1 b
436 436 .
437 437 .
438 438 .
439 439 @@ -10,7 +10,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xc3\xa0 (esc)
440 440 .
441 441 .
442 442 .
443 443 - 0 a with grave (single code point)
444 444 + 1 a with grave (single code point)
445 445 .
446 446 .
447 447 .
448 448 @@ -18,7 +18,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xcc\x80 (esc)
449 449 .
450 450 .
451 451 .
452 452 - 0 a with grave (composition)
453 453 + 1 a with grave (composition)
454 454 .
455 455 .
456 456 .
457 457
458 458 $ cd ..
459
460 Make sure `hg diff --git` differentiate "file did not exists" and "file is empty"
461 for git blob oids
462
463 $ hg init bloboids
464 $ cd bloboids
465
466 $ touch a
467 $ hg ci -Am "empty a"
468 adding a
469 $ hg diff -c 0 --git --config experimental.extendedheader.index=full | grep index
470 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
471
472 Make sure `hg diff --git` differentiate "file was empty" and "file is removed"
473 for git blob oids
474
475 $ rm a
476 $ hg ci -Am "removed a"
477 removing a
478 $ hg diff -c 1 --git --config experimental.extendedheader.index=full | grep index
479 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
480
481 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now