##// END OF EJS Templates
copies: add test that makes both the merging csets dirty and fails...
Sushil khanchi -
r42097:fc4b7a46 default
parent child Browse files
Show More
@@ -1,554 +1,633
1 1 #testcases filelog compatibility
2 2
3 3 $ cat >> $HGRCPATH << EOF
4 > [extensions]
5 > rebase=
4 6 > [alias]
5 7 > l = log -G -T '{rev} {desc}\n{files}\n'
6 8 > EOF
7 9
8 10 #if compatibility
9 11 $ cat >> $HGRCPATH << EOF
10 12 > [experimental]
11 13 > copies.read-from = compatibility
12 14 > EOF
13 15 #endif
14 16
15 17 $ REPONUM=0
16 18 $ newrepo() {
17 19 > cd $TESTTMP
18 20 > REPONUM=`expr $REPONUM + 1`
19 21 > hg init repo-$REPONUM
20 22 > cd repo-$REPONUM
21 23 > }
22 24
23 25 Simple rename case
24 26 $ newrepo
25 27 $ echo x > x
26 28 $ hg ci -Aqm 'add x'
27 29 $ hg mv x y
28 30 $ hg debugp1copies
29 31 x -> y
30 32 $ hg debugp2copies
31 33 $ hg ci -m 'rename x to y'
32 34 $ hg l
33 35 @ 1 rename x to y
34 36 | x y
35 37 o 0 add x
36 38 x
37 39 $ hg debugp1copies -r 1
38 40 x -> y
39 41 $ hg debugpathcopies 0 1
40 42 x -> y
41 43 $ hg debugpathcopies 1 0
42 44 y -> x
43 45 Test filtering copies by path. We do filtering by destination.
44 46 $ hg debugpathcopies 0 1 x
45 47 $ hg debugpathcopies 1 0 x
46 48 y -> x
47 49 $ hg debugpathcopies 0 1 y
48 50 x -> y
49 51 $ hg debugpathcopies 1 0 y
50 52
51 53 Copy a file onto another file
52 54 $ newrepo
53 55 $ echo x > x
54 56 $ echo y > y
55 57 $ hg ci -Aqm 'add x and y'
56 58 $ hg cp -f x y
57 59 $ hg debugp1copies
58 60 x -> y
59 61 $ hg debugp2copies
60 62 $ hg ci -m 'copy x onto y'
61 63 $ hg l
62 64 @ 1 copy x onto y
63 65 | y
64 66 o 0 add x and y
65 67 x y
66 68 $ hg debugp1copies -r 1
67 69 x -> y
68 70 Incorrectly doesn't show the rename
69 71 $ hg debugpathcopies 0 1
70 72
71 73 Copy a file onto another file with same content. If metadata is stored in changeset, this does not
72 74 produce a new filelog entry. The changeset's "files" entry should still list the file.
73 75 $ newrepo
74 76 $ echo x > x
75 77 $ echo x > x2
76 78 $ hg ci -Aqm 'add x and x2 with same content'
77 79 $ hg cp -f x x2
78 80 $ hg ci -m 'copy x onto x2'
79 81 $ hg l
80 82 @ 1 copy x onto x2
81 83 | x2
82 84 o 0 add x and x2 with same content
83 85 x x2
84 86 $ hg debugp1copies -r 1
85 87 x -> x2
86 88 Incorrectly doesn't show the rename
87 89 $ hg debugpathcopies 0 1
88 90
89 91 Copy a file, then delete destination, then copy again. This does not create a new filelog entry.
90 92 $ newrepo
91 93 $ echo x > x
92 94 $ hg ci -Aqm 'add x'
93 95 $ hg cp x y
94 96 $ hg ci -m 'copy x to y'
95 97 $ hg rm y
96 98 $ hg ci -m 'remove y'
97 99 $ hg cp -f x y
98 100 $ hg ci -m 'copy x onto y (again)'
99 101 $ hg l
100 102 @ 3 copy x onto y (again)
101 103 | y
102 104 o 2 remove y
103 105 | y
104 106 o 1 copy x to y
105 107 | y
106 108 o 0 add x
107 109 x
108 110 $ hg debugp1copies -r 3
109 111 x -> y
110 112 $ hg debugpathcopies 0 3
111 113 x -> y
112 114
113 115 Rename file in a loop: x->y->z->x
114 116 $ newrepo
115 117 $ echo x > x
116 118 $ hg ci -Aqm 'add x'
117 119 $ hg mv x y
118 120 $ hg debugp1copies
119 121 x -> y
120 122 $ hg debugp2copies
121 123 $ hg ci -m 'rename x to y'
122 124 $ hg mv y z
123 125 $ hg ci -m 'rename y to z'
124 126 $ hg mv z x
125 127 $ hg ci -m 'rename z to x'
126 128 $ hg l
127 129 @ 3 rename z to x
128 130 | x z
129 131 o 2 rename y to z
130 132 | y z
131 133 o 1 rename x to y
132 134 | x y
133 135 o 0 add x
134 136 x
135 137 $ hg debugpathcopies 0 3
136 138
137 139 Copy x to y, then remove y, then add back y. With copy metadata in the changeset, this could easily
138 140 end up reporting y as copied from x (if we don't unmark it as a copy when it's removed).
139 141 $ newrepo
140 142 $ echo x > x
141 143 $ hg ci -Aqm 'add x'
142 144 $ hg mv x y
143 145 $ hg ci -m 'rename x to y'
144 146 $ hg rm y
145 147 $ hg ci -qm 'remove y'
146 148 $ echo x > y
147 149 $ hg ci -Aqm 'add back y'
148 150 $ hg l
149 151 @ 3 add back y
150 152 | y
151 153 o 2 remove y
152 154 | y
153 155 o 1 rename x to y
154 156 | x y
155 157 o 0 add x
156 158 x
157 159 $ hg debugp1copies -r 3
158 160 $ hg debugpathcopies 0 3
159 161
160 162 Copy x to z, then remove z, then copy x2 (same content as x) to z. With copy metadata in the
161 163 changeset, the two copies here will have the same filelog entry, so ctx['z'].introrev() might point
162 164 to the first commit that added the file. We should still report the copy as being from x2.
163 165 $ newrepo
164 166 $ echo x > x
165 167 $ echo x > x2
166 168 $ hg ci -Aqm 'add x and x2 with same content'
167 169 $ hg cp x z
168 170 $ hg ci -qm 'copy x to z'
169 171 $ hg rm z
170 172 $ hg ci -m 'remove z'
171 173 $ hg cp x2 z
172 174 $ hg ci -m 'copy x2 to z'
173 175 $ hg l
174 176 @ 3 copy x2 to z
175 177 | z
176 178 o 2 remove z
177 179 | z
178 180 o 1 copy x to z
179 181 | z
180 182 o 0 add x and x2 with same content
181 183 x x2
182 184 $ hg debugp1copies -r 3
183 185 x2 -> z
184 186 $ hg debugpathcopies 0 3
185 187 x2 -> z
186 188
187 189 Create x and y, then rename them both to the same name, but on different sides of a fork
188 190 $ newrepo
189 191 $ echo x > x
190 192 $ echo y > y
191 193 $ hg ci -Aqm 'add x and y'
192 194 $ hg mv x z
193 195 $ hg ci -qm 'rename x to z'
194 196 $ hg co -q 0
195 197 $ hg mv y z
196 198 $ hg ci -qm 'rename y to z'
197 199 $ hg l
198 200 @ 2 rename y to z
199 201 | y z
200 202 | o 1 rename x to z
201 203 |/ x z
202 204 o 0 add x and y
203 205 x y
204 206 $ hg debugpathcopies 1 2
205 207 z -> x
206 208 y -> z
207 209
208 210 Fork renames x to y on one side and removes x on the other
209 211 $ newrepo
210 212 $ echo x > x
211 213 $ hg ci -Aqm 'add x'
212 214 $ hg mv x y
213 215 $ hg ci -m 'rename x to y'
214 216 $ hg co -q 0
215 217 $ hg rm x
216 218 $ hg ci -m 'remove x'
217 219 created new head
218 220 $ hg l
219 221 @ 2 remove x
220 222 | x
221 223 | o 1 rename x to y
222 224 |/ x y
223 225 o 0 add x
224 226 x
225 227 $ hg debugpathcopies 1 2
226 228
227 229 Copies via null revision (there shouldn't be any)
228 230 $ newrepo
229 231 $ echo x > x
230 232 $ hg ci -Aqm 'add x'
231 233 $ hg cp x y
232 234 $ hg ci -m 'copy x to y'
233 235 $ hg co -q null
234 236 $ echo x > x
235 237 $ hg ci -Aqm 'add x (again)'
236 238 $ hg l
237 239 @ 2 add x (again)
238 240 x
239 241 o 1 copy x to y
240 242 | y
241 243 o 0 add x
242 244 x
243 245 $ hg debugpathcopies 1 2
244 246 $ hg debugpathcopies 2 1
245 247
246 248 Merge rename from other branch
247 249 $ newrepo
248 250 $ echo x > x
249 251 $ hg ci -Aqm 'add x'
250 252 $ hg mv x y
251 253 $ hg ci -m 'rename x to y'
252 254 $ hg co -q 0
253 255 $ echo z > z
254 256 $ hg ci -Aqm 'add z'
255 257 $ hg merge -q 1
256 258 $ hg debugp1copies
257 259 $ hg debugp2copies
258 260 $ hg ci -m 'merge rename from p2'
259 261 $ hg l
260 262 @ 3 merge rename from p2
261 263 |\ x
262 264 | o 2 add z
263 265 | | z
264 266 o | 1 rename x to y
265 267 |/ x y
266 268 o 0 add x
267 269 x
268 270 Perhaps we should indicate the rename here, but `hg status` is documented to be weird during
269 271 merges, so...
270 272 $ hg debugp1copies -r 3
271 273 $ hg debugp2copies -r 3
272 274 $ hg debugpathcopies 0 3
273 275 x -> y
274 276 $ hg debugpathcopies 1 2
275 277 y -> x
276 278 $ hg debugpathcopies 1 3
277 279 $ hg debugpathcopies 2 3
278 280 x -> y
279 281
280 282 Copy file from either side in a merge
281 283 $ newrepo
282 284 $ echo x > x
283 285 $ hg ci -Aqm 'add x'
284 286 $ hg co -q null
285 287 $ echo y > y
286 288 $ hg ci -Aqm 'add y'
287 289 $ hg merge -q 0
288 290 $ hg cp y z
289 291 $ hg debugp1copies
290 292 y -> z
291 293 $ hg debugp2copies
292 294 $ hg ci -m 'copy file from p1 in merge'
293 295 $ hg co -q 1
294 296 $ hg merge -q 0
295 297 $ hg cp x z
296 298 $ hg debugp1copies
297 299 $ hg debugp2copies
298 300 x -> z
299 301 $ hg ci -qm 'copy file from p2 in merge'
300 302 $ hg l
301 303 @ 3 copy file from p2 in merge
302 304 |\ z
303 305 +---o 2 copy file from p1 in merge
304 306 | |/ z
305 307 | o 1 add y
306 308 | y
307 309 o 0 add x
308 310 x
309 311 $ hg debugp1copies -r 2
310 312 y -> z
311 313 $ hg debugp2copies -r 2
312 314 $ hg debugpathcopies 1 2
313 315 y -> z
314 316 $ hg debugpathcopies 0 2
315 317 $ hg debugp1copies -r 3
316 318 $ hg debugp2copies -r 3
317 319 x -> z
318 320 $ hg debugpathcopies 1 3
319 321 $ hg debugpathcopies 0 3
320 322 x -> z
321 323
322 324 Copy file that exists on both sides of the merge, same content on both sides
323 325 $ newrepo
324 326 $ echo x > x
325 327 $ hg ci -Aqm 'add x on branch 1'
326 328 $ hg co -q null
327 329 $ echo x > x
328 330 $ hg ci -Aqm 'add x on branch 2'
329 331 $ hg merge -q 0
330 332 $ hg cp x z
331 333 $ hg debugp1copies
332 334 x -> z
333 335 $ hg debugp2copies
334 336 $ hg ci -qm 'merge'
335 337 $ hg l
336 338 @ 2 merge
337 339 |\ z
338 340 | o 1 add x on branch 2
339 341 | x
340 342 o 0 add x on branch 1
341 343 x
342 344 $ hg debugp1copies -r 2
343 345 x -> z
344 346 $ hg debugp2copies -r 2
345 347 It's a little weird that it shows up on both sides
346 348 $ hg debugpathcopies 1 2
347 349 x -> z
348 350 $ hg debugpathcopies 0 2
349 351 x -> z (filelog !)
350 352
351 353 Copy file that exists on both sides of the merge, different content
352 354 $ newrepo
353 355 $ echo branch1 > x
354 356 $ hg ci -Aqm 'add x on branch 1'
355 357 $ hg co -q null
356 358 $ echo branch2 > x
357 359 $ hg ci -Aqm 'add x on branch 2'
358 360 $ hg merge -q 0
359 361 warning: conflicts while merging x! (edit, then use 'hg resolve --mark')
360 362 [1]
361 363 $ echo resolved > x
362 364 $ hg resolve -m x
363 365 (no more unresolved files)
364 366 $ hg cp x z
365 367 $ hg debugp1copies
366 368 x -> z
367 369 $ hg debugp2copies
368 370 $ hg ci -qm 'merge'
369 371 $ hg l
370 372 @ 2 merge
371 373 |\ x z
372 374 | o 1 add x on branch 2
373 375 | x
374 376 o 0 add x on branch 1
375 377 x
376 378 $ hg debugp1copies -r 2
377 379 $ hg debugp2copies -r 2
378 380 x -> z
379 381 $ hg debugpathcopies 1 2
380 382 $ hg debugpathcopies 0 2
381 383 x -> z
382 384
383 385 Copy x->y on one side of merge and copy x->z on the other side. Pathcopies from one parent
384 386 of the merge to the merge should include the copy from the other side.
385 387 $ newrepo
386 388 $ echo x > x
387 389 $ hg ci -Aqm 'add x'
388 390 $ hg cp x y
389 391 $ hg ci -qm 'copy x to y'
390 392 $ hg co -q 0
391 393 $ hg cp x z
392 394 $ hg ci -qm 'copy x to z'
393 395 $ hg merge -q 1
394 396 $ hg ci -m 'merge copy x->y and copy x->z'
395 397 $ hg l
396 398 @ 3 merge copy x->y and copy x->z
397 399 |\
398 400 | o 2 copy x to z
399 401 | | z
400 402 o | 1 copy x to y
401 403 |/ y
402 404 o 0 add x
403 405 x
404 406 $ hg debugp1copies -r 3
405 407 $ hg debugp2copies -r 3
406 408 $ hg debugpathcopies 2 3
407 409 x -> y
408 410 $ hg debugpathcopies 1 3
409 411 x -> z
410 412
411 413 Copy x to y on one side of merge, create y and rename to z on the other side. Pathcopies from the
412 414 first side should not include the y->z rename since y didn't exist in the merge base.
413 415 $ newrepo
414 416 $ echo x > x
415 417 $ hg ci -Aqm 'add x'
416 418 $ hg cp x y
417 419 $ hg ci -qm 'copy x to y'
418 420 $ hg co -q 0
419 421 $ echo y > y
420 422 $ hg ci -Aqm 'add y'
421 423 $ hg mv y z
422 424 $ hg ci -m 'rename y to z'
423 425 $ hg merge -q 1
424 426 $ hg ci -m 'merge'
425 427 $ hg l
426 428 @ 4 merge
427 429 |\
428 430 | o 3 rename y to z
429 431 | | y z
430 432 | o 2 add y
431 433 | | y
432 434 o | 1 copy x to y
433 435 |/ y
434 436 o 0 add x
435 437 x
436 438 $ hg debugp1copies -r 3
437 439 y -> z
438 440 $ hg debugp2copies -r 3
439 441 $ hg debugpathcopies 2 3
440 442 y -> z
441 443 $ hg debugpathcopies 1 3
442 444
443 445 Create x and y, then rename x to z on one side of merge, and rename y to z and modify z on the
444 446 other side.
445 447 $ newrepo
446 448 $ echo x > x
447 449 $ echo y > y
448 450 $ hg ci -Aqm 'add x and y'
449 451 $ hg mv x z
450 452 $ hg ci -qm 'rename x to z'
451 453 $ hg co -q 0
452 454 $ hg mv y z
453 455 $ hg ci -qm 'rename y to z'
454 456 $ echo z >> z
455 457 $ hg ci -m 'modify z'
456 458 $ hg merge -q 1
457 459 warning: conflicts while merging z! (edit, then use 'hg resolve --mark')
458 460 [1]
459 461 $ echo z > z
460 462 $ hg resolve -qm z
461 463 $ hg ci -m 'merge 1 into 3'
462 464 Try merging the other direction too
463 465 $ hg co -q 1
464 466 $ hg merge -q 3
465 467 warning: conflicts while merging z! (edit, then use 'hg resolve --mark')
466 468 [1]
467 469 $ echo z > z
468 470 $ hg resolve -qm z
469 471 $ hg ci -m 'merge 3 into 1'
470 472 created new head
471 473 $ hg l
472 474 @ 5 merge 3 into 1
473 475 |\ y z
474 476 +---o 4 merge 1 into 3
475 477 | |/ x z
476 478 | o 3 modify z
477 479 | | z
478 480 | o 2 rename y to z
479 481 | | y z
480 482 o | 1 rename x to z
481 483 |/ x z
482 484 o 0 add x and y
483 485 x y
484 486 $ hg debugpathcopies 1 4
485 487 $ hg debugpathcopies 2 4
486 488 $ hg debugpathcopies 0 4
487 489 x -> z (filelog !)
488 490 y -> z (compatibility !)
489 491 $ hg debugpathcopies 1 5
490 492 $ hg debugpathcopies 2 5
491 493 $ hg debugpathcopies 0 5
492 494 x -> z
493 495
494 496
495 497 Test for a case in fullcopytracing algorithm where both the merging csets are
496 498 "dirty"; where a dirty cset means that cset is descendant of merge base. This
497 499 test reflect that for this particular case this algorithm correctly find the copies:
498 500
499 501 $ cat >> $HGRCPATH << EOF
500 502 > [experimental]
501 503 > evolution.createmarkers=True
502 504 > evolution.allowunstable=True
503 505 > EOF
504 506
505 507 $ newrepo
506 508 $ echo a > a
507 509 $ hg add a
508 510 $ hg ci -m "added a"
509 511 $ echo b > b
510 512 $ hg add b
511 513 $ hg ci -m "added b"
512 514
513 515 $ hg mv b b1
514 516 $ hg ci -m "rename b to b1"
515 517
516 518 $ hg up ".^"
517 519 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
518 520 $ echo d > d
519 521 $ hg add d
520 522 $ hg ci -m "added d"
521 523 created new head
522 524
523 525 $ echo baba >> b
524 526 $ hg ci --amend -m "added d, modified b"
525 527
526 528 $ hg l --hidden
527 529 @ 4 added d, modified b
528 530 | b d
529 531 | x 3 added d
530 532 |/ d
531 533 | o 2 rename b to b1
532 534 |/ b b1
533 535 o 1 added b
534 536 | b
535 537 o 0 added a
536 538 a
537 539
538 540 Grafting revision 4 on top of revision 2, showing that it respect the rename:
539 541
540 542 $ hg up 2 -q
541 543 $ hg graft -r 4 --base 3 --hidden
542 544 grafting 4:af28412ec03c "added d, modified b" (tip)
543 545 merging b1 and b to b1
544 546
545 547 $ hg l -l1 -p
546 548 @ 5 added d, modified b
547 549 | b1
548 550 ~ diff -r 5a4825cc2926 -r 94a2f1a0e8e2 b1
549 551 --- a/b1 Thu Jan 01 00:00:00 1970 +0000
550 552 +++ b/b1 Thu Jan 01 00:00:00 1970 +0000
551 553 @@ -1,1 +1,2 @@
552 554 b
553 555 +baba
554 556
557 Test which demonstrate that fullcopytracing algorithm can fail to handle a case when both the csets are dirty
558 ----------------------------------------------------------------------------------------------------------
559
560 $ newrepo
561 $ echo a > a
562 $ hg add a
563 $ hg ci -m "added a"
564 $ echo b > b
565 $ hg add b
566 $ hg ci -m "added b"
567
568 $ echo foobar > willconflict
569 $ hg add willconflict
570 $ hg ci -m "added willconflict"
571 $ echo c > c
572 $ hg add c
573 $ hg ci -m "added c"
574
575 $ hg l
576 @ 3 added c
577 | c
578 o 2 added willconflict
579 | willconflict
580 o 1 added b
581 | b
582 o 0 added a
583 a
584
585 $ hg up ".^^"
586 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
587 $ echo d > d
588 $ hg add d
589 $ hg ci -m "added d"
590 created new head
591
592 $ echo barfoo > willconflict
593 $ hg add willconflict
594 $ hg ci --amend -m "added willconflict and d"
595
596 $ hg l
597 @ 5 added willconflict and d
598 | d willconflict
599 | o 3 added c
600 | | c
601 | o 2 added willconflict
602 |/ willconflict
603 o 1 added b
604 | b
605 o 0 added a
606 a
607
608 $ hg rebase -r . -d 2 -t :other
609 rebasing 5:5018b1509e94 "added willconflict and d" (tip)
610
611 $ hg up 3 -q
612 $ hg l --hidden
613 o 6 added willconflict and d
614 | d willconflict
615 | x 5 added willconflict and d
616 | | d willconflict
617 | | x 4 added d
618 | |/ d
619 +---@ 3 added c
620 | | c
621 o | 2 added willconflict
622 |/ willconflict
623 o 1 added b
624 | b
625 o 0 added a
626 a
627
628 Now if we trigger a merge between cset revision 3 and 6 using base revision 4, in this case
629 both the merging csets will be dirty as no one is descendent of base revision:
630
631 $ hg graft -r 6 --base 4 --hidden 2>&1 | grep "AssertionError"
632 AssertionError
633
General Comments 0
You need to be logged in to leave comments. Login now