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