Debian Codegraph @

tests/test-git-export.t

raw
1 $ hg init repo
2 $ cd repo
3 $ echo start > start
4 $ hg ci -Amstart
5 adding start
6
7 New file:
8
9 $ mkdir dir1
10 $ echo new > dir1/new
11 $ hg ci -Amnew
12 adding dir1/new
13 $ hg diff --git -r 0
14 diff --git a/dir1/new b/dir1/new
15 new file mode 100644
16 --- /dev/null
17 +++ b/dir1/new
18 @@ -0,0 +1,1 @@
19 +new
20
21 Copy:
22
23 $ mkdir dir2
24 $ hg cp dir1/new dir1/copy
25 $ echo copy1 >> dir1/copy
26 $ hg cp dir1/new dir2/copy
27 $ echo copy2 >> dir2/copy
28 $ hg ci -mcopy
29 $ hg diff --git -r 1:tip
30 diff --git a/dir1/new b/dir1/copy
31 copy from dir1/new
32 copy to dir1/copy
33 --- a/dir1/new
34 +++ b/dir1/copy
35 @@ -1,1 +1,2 @@
36 new
37 +copy1
38 diff --git a/dir1/new b/dir2/copy
39 copy from dir1/new
40 copy to dir2/copy
41 --- a/dir1/new
42 +++ b/dir2/copy
43 @@ -1,1 +1,2 @@
44 new
45 +copy2
46
47 Cross and same-directory copies with a relative root:
48
49 $ hg diff --git --root .. -r 1:tip
50 abort: .. not under root '$TESTTMP/repo'
51 [255]
52 $ hg diff --git --root doesnotexist -r 1:tip
53 $ hg diff --git --root . -r 1:tip
54 diff --git a/dir1/new b/dir1/copy
55 copy from dir1/new
56 copy to dir1/copy
57 --- a/dir1/new
58 +++ b/dir1/copy
59 @@ -1,1 +1,2 @@
60 new
61 +copy1
62 diff --git a/dir1/new b/dir2/copy
63 copy from dir1/new
64 copy to dir2/copy
65 --- a/dir1/new
66 +++ b/dir2/copy
67 @@ -1,1 +1,2 @@
68 new
69 +copy2
70 $ hg diff --git --root dir1 -r 1:tip
71 diff --git a/new b/copy
72 copy from new
73 copy to copy
74 --- a/new
75 +++ b/copy
76 @@ -1,1 +1,2 @@
77 new
78 +copy1
79
80 $ hg diff --git --root dir2/ -r 1:tip
81 diff --git a/copy b/copy
82 new file mode 100644
83 --- /dev/null
84 +++ b/copy
85 @@ -0,0 +1,2 @@
86 +new
87 +copy2
88
89 $ hg diff --git --root dir1 -r 1:tip -I '**/copy'
90 diff --git a/new b/copy
91 copy from new
92 copy to copy
93 --- a/new
94 +++ b/copy
95 @@ -1,1 +1,2 @@
96 new
97 +copy1
98
99 $ hg diff --git --root dir1 -r 1:tip dir2
100 warning: dir2 not inside relative root dir1
101
102 $ hg diff --git --root dir1 -r 1:tip 'dir2/{copy}'
103 warning: dir2/{copy} not inside relative root dir1
104
105 $ cd dir1
106 $ hg diff --git --root .. -r 1:tip
107 diff --git a/dir1/new b/dir1/copy
108 copy from dir1/new
109 copy to dir1/copy
110 --- a/dir1/new
111 +++ b/dir1/copy
112 @@ -1,1 +1,2 @@
113 new
114 +copy1
115 diff --git a/dir1/new b/dir2/copy
116 copy from dir1/new
117 copy to dir2/copy
118 --- a/dir1/new
119 +++ b/dir2/copy
120 @@ -1,1 +1,2 @@
121 new
122 +copy2
123
124 $ hg diff --git --root ../.. -r 1:tip
125 abort: ../.. not under root '$TESTTMP/repo'
126 [255]
127 $ hg diff --git --root ../doesnotexist -r 1:tip
128 $ hg diff --git --root .. -r 1:tip
129 diff --git a/dir1/new b/dir1/copy
130 copy from dir1/new
131 copy to dir1/copy
132 --- a/dir1/new
133 +++ b/dir1/copy
134 @@ -1,1 +1,2 @@
135 new
136 +copy1
137 diff --git a/dir1/new b/dir2/copy
138 copy from dir1/new
139 copy to dir2/copy
140 --- a/dir1/new
141 +++ b/dir2/copy
142 @@ -1,1 +1,2 @@
143 new
144 +copy2
145
146 $ hg diff --git --root . -r 1:tip
147 diff --git a/new b/copy
148 copy from new
149 copy to copy
150 --- a/new
151 +++ b/copy
152 @@ -1,1 +1,2 @@
153 new
154 +copy1
155 $ hg diff --git --root . -r 1:tip copy
156 diff --git a/new b/copy
157 copy from new
158 copy to copy
159 --- a/new
160 +++ b/copy
161 @@ -1,1 +1,2 @@
162 new
163 +copy1
164 $ hg diff --git --root . -r 1:tip ../dir2
165 warning: ../dir2 not inside relative root .
166 $ hg diff --git --root . -r 1:tip '../dir2/*'
167 warning: ../dir2/* not inside relative root . (glob)
168 $ cd ..
169
170 Rename:
171
172 $ hg mv dir1/copy dir1/rename1
173 $ echo rename1 >> dir1/rename1
174 $ hg mv dir2/copy dir1/rename2
175 $ echo rename2 >> dir1/rename2
176 $ hg ci -mrename
177 $ hg diff --git -r 2:tip
178 diff --git a/dir1/copy b/dir1/rename1
179 rename from dir1/copy
180 rename to dir1/rename1
181 --- a/dir1/copy
182 +++ b/dir1/rename1
183 @@ -1,2 +1,3 @@
184 new
185 copy1
186 +rename1
187 diff --git a/dir2/copy b/dir1/rename2
188 rename from dir2/copy
189 rename to dir1/rename2
190 --- a/dir2/copy
191 +++ b/dir1/rename2
192 @@ -1,2 +1,3 @@
193 new
194 copy2
195 +rename2
196
197 Cross and same-directory renames with a relative root:
198
199 $ hg diff --root dir1 --git -r 2:tip
200 diff --git a/copy b/rename1
201 rename from copy
202 rename to rename1
203 --- a/copy
204 +++ b/rename1
205 @@ -1,2 +1,3 @@
206 new
207 copy1
208 +rename1
209 diff --git a/rename2 b/rename2
210 new file mode 100644
211 --- /dev/null
212 +++ b/rename2
213 @@ -0,0 +1,3 @@
214 +new
215 +copy2
216 +rename2
217
218 $ hg diff --root dir2 --git -r 2:tip
219 diff --git a/copy b/copy
220 deleted file mode 100644
221 --- a/copy
222 +++ /dev/null
223 @@ -1,2 +0,0 @@
224 -new
225 -copy2
226
227 $ hg diff --root dir1 --git -r 2:tip -I '**/copy'
228 diff --git a/copy b/copy
229 deleted file mode 100644
230 --- a/copy
231 +++ /dev/null
232 @@ -1,2 +0,0 @@
233 -new
234 -copy1
235
236 $ hg diff --root dir1 --git -r 2:tip -I '**/rename*'
237 diff --git a/copy b/rename1
238 copy from copy
239 copy to rename1
240 --- a/copy
241 +++ b/rename1
242 @@ -1,2 +1,3 @@
243 new
244 copy1
245 +rename1
246 diff --git a/rename2 b/rename2
247 new file mode 100644
248 --- /dev/null
249 +++ b/rename2
250 @@ -0,0 +1,3 @@
251 +new
252 +copy2
253 +rename2
254
255 Delete:
256
257 $ hg rm dir1/*
258 $ hg ci -mdelete
259 $ hg diff --git -r 3:tip
260 diff --git a/dir1/new b/dir1/new
261 deleted file mode 100644
262 --- a/dir1/new
263 +++ /dev/null
264 @@ -1,1 +0,0 @@
265 -new
266 diff --git a/dir1/rename1 b/dir1/rename1
267 deleted file mode 100644
268 --- a/dir1/rename1
269 +++ /dev/null
270 @@ -1,3 +0,0 @@
271 -new
272 -copy1
273 -rename1
274 diff --git a/dir1/rename2 b/dir1/rename2
275 deleted file mode 100644
276 --- a/dir1/rename2
277 +++ /dev/null
278 @@ -1,3 +0,0 @@
279 -new
280 -copy2
281 -rename2
282
283 $ cat > src <<EOF
284 > 1
285 > 2
286 > 3
287 > 4
288 > 5
289 > EOF
290 $ hg ci -Amsrc
291 adding src
292
293 #if execbit
294
295 chmod 644:
296
297 $ chmod +x src
298 $ hg ci -munexec
299 $ hg diff --git -r 5:tip
300 diff --git a/src b/src
301 old mode 100644
302 new mode 100755
303
304 Rename+mod+chmod:
305
306 $ hg mv src dst
307 $ chmod -x dst
308 $ echo a >> dst
309 $ hg ci -mrenamemod
310 $ hg diff --git -r 6:tip
311 diff --git a/src b/dst
312 old mode 100755
313 new mode 100644
314 rename from src
315 rename to dst
316 --- a/src
317 +++ b/dst
318 @@ -3,3 +3,4 @@
319 3
320 4
321 5
322 +a
323
324 Nonexistent in tip+chmod:
325
326 $ hg diff --git -r 5:6
327 diff --git a/src b/src
328 old mode 100644
329 new mode 100755
330
331 #else
332
333 Dummy changes when no exec bit, mocking the execbit commit structure
334
335 $ echo change >> src
336 $ hg ci -munexec
337 $ hg mv src dst
338 $ hg ci -mrenamemod
339
340 #endif
341
342 Binary diff:
343
344 $ cp "$TESTDIR/binfile.bin" .
345 $ hg add binfile.bin
346 $ hg diff --git > b.diff
347 $ cat b.diff
348 diff --git a/binfile.bin b/binfile.bin
349 new file mode 100644
350 index 0000000000000000000000000000000000000000..37ba3d1c6f17137d9c5f5776fa040caf5fe73ff9
351 GIT binary patch
352 literal 593
353 zc$@)I0<QguP)<h;3K|Lk000e1NJLTq000mG000mO0ssI2kdbIM00009a7bBm000XU
354 z000XU0RWnu7ytkO2XskIMF-Uh9TW;VpMjwv0005-Nkl<ZD9@FWPs=e;7{<>W$NUkd
355 zX$nnYLt$-$V!?uy+1V%`z&Eh=ah|duER<4|QWhju3gb^nF*8iYobxWG-qqXl=2~5M
356 z*IoDB)sG^CfNuoBmqLTVU^<;@nwHP!1wrWd`{(mHo6VNXWtyh{alzqmsH*yYzpvLT
357 zLdY<T=ks|woh-`&01!ej#(xbV1f|pI*=%;d-%F*E*X#ZH`4I%6SS+$EJDE&ct=8po
358 ziN#{?_j|kD%Cd|oiqds`xm@;oJ-^?NG3Gdqrs?5u*zI;{nogxsx~^|Fn^Y?Gdc6<;
359 zfMJ+iF1J`LMx&A2?dEwNW8ClebzPTbIh{@$hS6*`kH@1d%Lo7fA#}N1)oN7`gm$~V
360 z+wDx#)OFqMcE{s!JN0-xhG8ItAjVkJwEcb`3WWlJfU2r?;Pd%dmR+q@mSri5q9_W-
361 zaR2~ECX?B2w+zELozC0s*6Z~|QG^f{3I#<`?)Q7U-JZ|q5W;9Q8i_=pBuSzunx=U;
362 z9C)5jBoYw9^?EHyQl(M}1OlQcCX>lXB*ODN003Z&P17_@)3Pi=i0wb04<W?v-u}7K
363 zXmmQA+wDgE!qR9o8jr`%=ab_&uh(l?R=r;Tjiqon91I2-hIu?57~@*4h7h9uORK#=
364 fQItJW-{SoTm)8|5##k|m00000NkvXXu0mjf{mKw4
365
366
367 Import binary diff:
368
369 $ hg revert binfile.bin
370 $ rm binfile.bin
371 $ hg import -mfoo b.diff
372 applying b.diff
373 $ cmp binfile.bin "$TESTDIR/binfile.bin"
374
375 Rename binary file:
376
377 $ hg mv binfile.bin renamed.bin
378 $ hg diff --git
379 diff --git a/binfile.bin b/renamed.bin
380 rename from binfile.bin
381 rename to renamed.bin
382
383 Diff across many revisions:
384
385 $ hg mv dst dst2
386 $ hg ci -m 'mv dst dst2'
387
388 $ echo >> start
389 $ hg ci -m 'change start'
390
391 $ hg revert -r -2 start
392 $ hg mv dst2 dst3
393 $ hg ci -m 'mv dst2 dst3; revert start'
394
395 $ hg diff --git -r 9:11
396 diff --git a/dst2 b/dst3
397 rename from dst2
398 rename to dst3
399
400 Reversed:
401
402 $ hg diff --git -r 11:9
403 diff --git a/dst3 b/dst2
404 rename from dst3
405 rename to dst2
406
407
408 $ echo a >> foo
409 $ hg add foo
410 $ hg ci -m 'add foo'
411 $ echo b >> foo
412 $ hg ci -m 'change foo'
413 $ hg mv foo bar
414 $ hg ci -m 'mv foo bar'
415 $ echo c >> bar
416 $ hg ci -m 'change bar'
417
418 File created before r1 and renamed before r2:
419
420 $ hg diff --git -r -3:-1
421 diff --git a/foo b/bar
422 rename from foo
423 rename to bar
424 --- a/foo
425 +++ b/bar
426 @@ -1,2 +1,3 @@
427 a
428 b
429 +c
430
431 Reversed:
432
433 $ hg diff --git -r -1:-3
434 diff --git a/bar b/foo
435 rename from bar
436 rename to foo
437 --- a/bar
438 +++ b/foo
439 @@ -1,3 +1,2 @@
440 a
441 b
442 -c
443
444 File created in r1 and renamed before r2:
445
446 $ hg diff --git -r -4:-1
447 diff --git a/foo b/bar
448 rename from foo
449 rename to bar
450 --- a/foo
451 +++ b/bar
452 @@ -1,1 +1,3 @@
453 a
454 +b
455 +c
456
457 Reversed:
458
459 $ hg diff --git -r -1:-4
460 diff --git a/bar b/foo
461 rename from bar
462 rename to foo
463 --- a/bar
464 +++ b/foo
465 @@ -1,3 +1,1 @@
466 a
467 -b
468 -c
469
470 File created after r1 and renamed before r2:
471
472 $ hg diff --git -r -5:-1
473 diff --git a/bar b/bar
474 new file mode 100644
475 --- /dev/null
476 +++ b/bar
477 @@ -0,0 +1,3 @@
478 +a
479 +b
480 +c
481
482 Reversed:
483
484 $ hg diff --git -r -1:-5
485 diff --git a/bar b/bar
486 deleted file mode 100644
487 --- a/bar
488 +++ /dev/null
489 @@ -1,3 +0,0 @@
490 -a
491 -b
492 -c
493
494
495 Comparing with the working dir:
496
497 $ echo >> start
498 $ hg ci -m 'change start again'
499
500 $ echo > created
501 $ hg add created
502 $ hg ci -m 'add created'
503
504 $ hg mv created created2
505 $ hg ci -m 'mv created created2'
506
507 $ hg mv created2 created3
508
509 There's a copy in the working dir:
510
511 $ hg diff --git
512 diff --git a/created2 b/created3
513 rename from created2
514 rename to created3
515
516 There's another copy between the original rev and the wd:
517
518 $ hg diff --git -r -2
519 diff --git a/created b/created3
520 rename from created
521 rename to created3
522
523 The source of the copy was created after the original rev:
524
525 $ hg diff --git -r -3
526 diff --git a/created3 b/created3
527 new file mode 100644
528 --- /dev/null
529 +++ b/created3
530 @@ -0,0 +1,1 @@
531 +
532 $ hg ci -m 'mv created2 created3'
533
534
535 $ echo > brand-new
536 $ hg add brand-new
537 $ hg ci -m 'add brand-new'
538 $ hg mv brand-new brand-new2
539
540 Created in parent of wd; renamed in the wd:
541
542 $ hg diff --git
543 diff --git a/brand-new b/brand-new2
544 rename from brand-new
545 rename to brand-new2
546
547 Created between r1 and parent of wd; renamed in the wd:
548
549 $ hg diff --git -r -2
550 diff --git a/brand-new2 b/brand-new2
551 new file mode 100644
552 --- /dev/null
553 +++ b/brand-new2
554 @@ -0,0 +1,1 @@
555 +
556 $ hg ci -m 'mv brand-new brand-new2'
557
558 One file is copied to many destinations and removed:
559
560 $ hg cp brand-new2 brand-new3
561 $ hg mv brand-new2 brand-new3-2
562 $ hg ci -m 'multiple renames/copies'
563 $ hg diff --git -r -2 -r -1
564 diff --git a/brand-new2 b/brand-new3
565 rename from brand-new2
566 rename to brand-new3
567 diff --git a/brand-new2 b/brand-new3-2
568 copy from brand-new2
569 copy to brand-new3-2
570
571 Reversed:
572
573 $ hg diff --git -r -1 -r -2
574 diff --git a/brand-new3-2 b/brand-new2
575 rename from brand-new3-2
576 rename to brand-new2
577 diff --git a/brand-new3 b/brand-new3
578 deleted file mode 100644
579 --- a/brand-new3
580 +++ /dev/null
581 @@ -1,1 +0,0 @@
582 -
583
584 There should be a trailing TAB if there are spaces in the file name:
585
586 $ echo foo > 'with spaces'
587 $ hg add 'with spaces'
588 $ hg diff --git
589 diff --git a/with spaces b/with spaces
590 new file mode 100644
591 --- /dev/null
592 +++ b/with spaces
593 @@ -0,0 +1,1 @@
594 +foo
595 $ hg ci -m 'add filename with spaces'
596
597 Additions should be properly marked even in the middle of a merge
598
599 $ hg up -r -2
600 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
601 $ echo "New File" >> inmerge
602 $ hg add inmerge
603 $ hg ci -m "file in merge"
604 created new head
605 $ hg up 23
606 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
607 $ hg merge
608 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
609 (branch merge, don't forget to commit)
610 $ hg diff -g
611 diff --git a/inmerge b/inmerge
612 new file mode 100644
613 --- /dev/null
614 +++ b/inmerge
615 @@ -0,0 +1,1 @@
616 +New File