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