##// END OF EJS Templates
rebase: add tests showing patch conflict detection needs to be smarter in IMM...
Pulkit Goyal -
r39611:aa022f88 default
parent child Browse files
Show More
@@ -1,584 +1,626 b''
1 1 #require symlink execbit
2 2 $ cat << EOF >> $HGRCPATH
3 3 > [extensions]
4 4 > amend=
5 5 > rebase=
6 6 > debugdrawdag=$TESTDIR/drawdag.py
7 7 > strip=
8 8 > [rebase]
9 9 > experimental.inmemory=1
10 10 > [diff]
11 11 > git=1
12 12 > [alias]
13 13 > tglog = log -G --template "{rev}: {node|short} '{desc}'\n"
14 14 > EOF
15 15
16 16 Rebase a simple DAG:
17 17 $ hg init repo1
18 18 $ cd repo1
19 19 $ hg debugdrawdag <<'EOS'
20 20 > c b
21 21 > |/
22 22 > d
23 23 > |
24 24 > a
25 25 > EOS
26 26 $ hg up -C a
27 27 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28 28 $ hg tglog
29 29 o 3: 814f6bd05178 'c'
30 30 |
31 31 | o 2: db0e82a16a62 'b'
32 32 |/
33 33 o 1: 02952614a83d 'd'
34 34 |
35 35 @ 0: b173517d0057 'a'
36 36
37 37 $ hg cat -r 3 c
38 38 c (no-eol)
39 39 $ hg cat -r 2 b
40 40 b (no-eol)
41 41 $ hg rebase --debug -r b -d c | grep rebasing
42 42 rebasing in-memory
43 43 rebasing 2:db0e82a16a62 "b" (b)
44 44 $ hg tglog
45 45 o 3: ca58782ad1e4 'b'
46 46 |
47 47 o 2: 814f6bd05178 'c'
48 48 |
49 49 o 1: 02952614a83d 'd'
50 50 |
51 51 @ 0: b173517d0057 'a'
52 52
53 53 $ hg cat -r 3 b
54 54 b (no-eol)
55 55 $ hg cat -r 2 c
56 56 c (no-eol)
57 57
58 58 Case 2:
59 59 $ hg init repo2
60 60 $ cd repo2
61 61 $ hg debugdrawdag <<'EOS'
62 62 > c b
63 63 > |/
64 64 > d
65 65 > |
66 66 > a
67 67 > EOS
68 68
69 69 Add a symlink and executable file:
70 70 $ hg up -C c
71 71 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
72 72 $ ln -s somefile e
73 73 $ echo f > f
74 74 $ chmod +x f
75 75 $ hg add e f
76 76 $ hg amend -q
77 77 $ hg up -Cq a
78 78
79 79 Write files to the working copy, and ensure they're still there after the rebase
80 80 $ echo "abc" > a
81 81 $ ln -s def b
82 82 $ echo "ghi" > c
83 83 $ echo "jkl" > d
84 84 $ echo "mno" > e
85 85 $ hg tglog
86 86 o 3: f56b71190a8f 'c'
87 87 |
88 88 | o 2: db0e82a16a62 'b'
89 89 |/
90 90 o 1: 02952614a83d 'd'
91 91 |
92 92 @ 0: b173517d0057 'a'
93 93
94 94 $ hg cat -r 3 c
95 95 c (no-eol)
96 96 $ hg cat -r 2 b
97 97 b (no-eol)
98 98 $ hg cat -r 3 e
99 99 somefile (no-eol)
100 100 $ hg rebase --debug -s b -d a | grep rebasing
101 101 rebasing in-memory
102 102 rebasing 2:db0e82a16a62 "b" (b)
103 103 $ hg tglog
104 104 o 3: fc055c3b4d33 'b'
105 105 |
106 106 | o 2: f56b71190a8f 'c'
107 107 | |
108 108 | o 1: 02952614a83d 'd'
109 109 |/
110 110 @ 0: b173517d0057 'a'
111 111
112 112 $ hg cat -r 2 c
113 113 c (no-eol)
114 114 $ hg cat -r 3 b
115 115 b (no-eol)
116 116 $ hg rebase --debug -s 1 -d 3 | grep rebasing
117 117 rebasing in-memory
118 118 rebasing 1:02952614a83d "d" (d)
119 119 rebasing 2:f56b71190a8f "c"
120 120 $ hg tglog
121 121 o 3: 753feb6fd12a 'c'
122 122 |
123 123 o 2: 09c044d2cb43 'd'
124 124 |
125 125 o 1: fc055c3b4d33 'b'
126 126 |
127 127 @ 0: b173517d0057 'a'
128 128
129 129 Ensure working copy files are still there:
130 130 $ cat a
131 131 abc
132 132 $ readlink.py b
133 133 b -> def
134 134 $ cat e
135 135 mno
136 136
137 137 Ensure symlink and executable files were rebased properly:
138 138 $ hg up -Cq 3
139 139 $ readlink.py e
140 140 e -> somefile
141 141 $ ls -l f | cut -c -10
142 142 -rwxr-xr-x
143 143
144 144 Rebase the working copy parent
145 145 $ hg up -C 3
146 146 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
147 147 $ hg rebase -r 3 -d 0 --debug | grep rebasing
148 148 rebasing in-memory
149 149 rebasing 3:753feb6fd12a "c" (tip)
150 150 $ hg tglog
151 151 @ 3: 844a7de3e617 'c'
152 152 |
153 153 | o 2: 09c044d2cb43 'd'
154 154 | |
155 155 | o 1: fc055c3b4d33 'b'
156 156 |/
157 157 o 0: b173517d0057 'a'
158 158
159 159
160 160 Test reporting of path conflicts
161 161
162 162 $ hg rm a
163 163 $ mkdir a
164 164 $ touch a/a
165 165 $ hg ci -Am "a/a"
166 166 adding a/a
167 167 $ hg tglog
168 168 @ 4: daf7dfc139cb 'a/a'
169 169 |
170 170 o 3: 844a7de3e617 'c'
171 171 |
172 172 | o 2: 09c044d2cb43 'd'
173 173 | |
174 174 | o 1: fc055c3b4d33 'b'
175 175 |/
176 176 o 0: b173517d0057 'a'
177 177
178 178 $ hg rebase -r . -d 2
179 179 rebasing 4:daf7dfc139cb "a/a" (tip)
180 180 saved backup bundle to $TESTTMP/repo1/repo2/.hg/strip-backup/daf7dfc139cb-fdbfcf4f-rebase.hg
181 181
182 $ hg tglog
183 @ 4: c6ad37a4f250 'a/a'
184 |
185 | o 3: 844a7de3e617 'c'
186 | |
187 o | 2: 09c044d2cb43 'd'
188 | |
189 o | 1: fc055c3b4d33 'b'
190 |/
191 o 0: b173517d0057 'a'
192
193 $ echo foo > foo
194 $ hg ci -Aqm "added foo"
195 $ hg up '.^'
196 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
197 $ echo bar > bar
198 $ hg ci -Aqm "added bar"
199 $ hg rm a/a
200 $ echo a > a
201 $ hg ci -Aqm "added a back!"
202 $ hg tglog
203 @ 7: 855e9797387e 'added a back!'
204 |
205 o 6: d14530e5e3e6 'added bar'
206 |
207 | o 5: 9b94b9373deb 'added foo'
208 |/
209 o 4: c6ad37a4f250 'a/a'
210 |
211 | o 3: 844a7de3e617 'c'
212 | |
213 o | 2: 09c044d2cb43 'd'
214 | |
215 o | 1: fc055c3b4d33 'b'
216 |/
217 o 0: b173517d0057 'a'
218
219 $ hg rebase -r . -d 5
220 rebasing 7:855e9797387e "added a back!" (tip)
221 abort: error: file 'a' cannot be written because 'a/' is a folder in 9b94b9373deb (containing 1 entries: a/a)
222 [255]
223
182 224 $ cd ..
183 225
184 226 Test dry-run rebasing
185 227
186 228 $ hg init repo3
187 229 $ cd repo3
188 230 $ echo a>a
189 231 $ hg ci -Aqma
190 232 $ echo b>b
191 233 $ hg ci -Aqmb
192 234 $ echo c>c
193 235 $ hg ci -Aqmc
194 236 $ echo d>d
195 237 $ hg ci -Aqmd
196 238 $ echo e>e
197 239 $ hg ci -Aqme
198 240
199 241 $ hg up 1 -q
200 242 $ echo f>f
201 243 $ hg ci -Amf
202 244 adding f
203 245 created new head
204 246 $ echo g>g
205 247 $ hg ci -Aqmg
206 248 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
207 249 @ 6:baf10c5166d4 test
208 250 | g
209 251 |
210 252 o 5:6343ca3eff20 test
211 253 | f
212 254 |
213 255 | o 4:e860deea161a test
214 256 | | e
215 257 | |
216 258 | o 3:055a42cdd887 test
217 259 | | d
218 260 | |
219 261 | o 2:177f92b77385 test
220 262 |/ c
221 263 |
222 264 o 1:d2ae7f538514 test
223 265 | b
224 266 |
225 267 o 0:cb9a9f314b8b test
226 268 a
227 269
228 270 Make sure it throws error while passing --continue or --abort with --dry-run
229 271 $ hg rebase -s 2 -d 6 -n --continue
230 272 abort: cannot specify both --dry-run and --continue
231 273 [255]
232 274 $ hg rebase -s 2 -d 6 -n --abort
233 275 abort: cannot specify both --dry-run and --abort
234 276 [255]
235 277
236 278 Check dryrun gives correct results when there is no conflict in rebasing
237 279 $ hg rebase -s 2 -d 6 -n
238 280 starting dry-run rebase; repository will not be changed
239 281 rebasing 2:177f92b77385 "c"
240 282 rebasing 3:055a42cdd887 "d"
241 283 rebasing 4:e860deea161a "e"
242 284 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
243 285
244 286 $ hg diff
245 287 $ hg status
246 288
247 289 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
248 290 @ 6:baf10c5166d4 test
249 291 | g
250 292 |
251 293 o 5:6343ca3eff20 test
252 294 | f
253 295 |
254 296 | o 4:e860deea161a test
255 297 | | e
256 298 | |
257 299 | o 3:055a42cdd887 test
258 300 | | d
259 301 | |
260 302 | o 2:177f92b77385 test
261 303 |/ c
262 304 |
263 305 o 1:d2ae7f538514 test
264 306 | b
265 307 |
266 308 o 0:cb9a9f314b8b test
267 309 a
268 310
269 311 Check dryrun working with --collapse when there is no conflict
270 312 $ hg rebase -s 2 -d 6 -n --collapse
271 313 starting dry-run rebase; repository will not be changed
272 314 rebasing 2:177f92b77385 "c"
273 315 rebasing 3:055a42cdd887 "d"
274 316 rebasing 4:e860deea161a "e"
275 317 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
276 318
277 319 Check dryrun gives correct results when there is conflict in rebasing
278 320 Make a conflict:
279 321 $ hg up 6 -q
280 322 $ echo conflict>e
281 323 $ hg ci -Aqm "conflict with e"
282 324 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
283 325 @ 7:d2c195b28050 test
284 326 | conflict with e
285 327 |
286 328 o 6:baf10c5166d4 test
287 329 | g
288 330 |
289 331 o 5:6343ca3eff20 test
290 332 | f
291 333 |
292 334 | o 4:e860deea161a test
293 335 | | e
294 336 | |
295 337 | o 3:055a42cdd887 test
296 338 | | d
297 339 | |
298 340 | o 2:177f92b77385 test
299 341 |/ c
300 342 |
301 343 o 1:d2ae7f538514 test
302 344 | b
303 345 |
304 346 o 0:cb9a9f314b8b test
305 347 a
306 348
307 349 $ hg rebase -s 2 -d 7 -n
308 350 starting dry-run rebase; repository will not be changed
309 351 rebasing 2:177f92b77385 "c"
310 352 rebasing 3:055a42cdd887 "d"
311 353 rebasing 4:e860deea161a "e"
312 354 merging e
313 355 transaction abort!
314 356 rollback completed
315 357 hit a merge conflict
316 358 [1]
317 359 $ hg diff
318 360 $ hg status
319 361 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
320 362 @ 7:d2c195b28050 test
321 363 | conflict with e
322 364 |
323 365 o 6:baf10c5166d4 test
324 366 | g
325 367 |
326 368 o 5:6343ca3eff20 test
327 369 | f
328 370 |
329 371 | o 4:e860deea161a test
330 372 | | e
331 373 | |
332 374 | o 3:055a42cdd887 test
333 375 | | d
334 376 | |
335 377 | o 2:177f92b77385 test
336 378 |/ c
337 379 |
338 380 o 1:d2ae7f538514 test
339 381 | b
340 382 |
341 383 o 0:cb9a9f314b8b test
342 384 a
343 385
344 386 Check dryrun working with --collapse when there is conflicts
345 387 $ hg rebase -s 2 -d 7 -n --collapse
346 388 starting dry-run rebase; repository will not be changed
347 389 rebasing 2:177f92b77385 "c"
348 390 rebasing 3:055a42cdd887 "d"
349 391 rebasing 4:e860deea161a "e"
350 392 merging e
351 393 hit a merge conflict
352 394 [1]
353 395
354 396 In-memory rebase that fails due to merge conflicts
355 397
356 398 $ hg rebase -s 2 -d 7
357 399 rebasing 2:177f92b77385 "c"
358 400 rebasing 3:055a42cdd887 "d"
359 401 rebasing 4:e860deea161a "e"
360 402 merging e
361 403 transaction abort!
362 404 rollback completed
363 405 hit merge conflicts; re-running rebase without in-memory merge
364 406 rebase aborted
365 407 rebasing 2:177f92b77385 "c"
366 408 rebasing 3:055a42cdd887 "d"
367 409 rebasing 4:e860deea161a "e"
368 410 merging e
369 411 warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
370 412 unresolved conflicts (see hg resolve, then hg rebase --continue)
371 413 [1]
372 414
373 415 ==========================
374 416 Test for --confirm option|
375 417 ==========================
376 418 $ cd ..
377 419 $ hg clone repo3 repo4 -q
378 420 $ cd repo4
379 421 $ hg strip 7 -q
380 422 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
381 423 @ 6:baf10c5166d4 test
382 424 | g
383 425 |
384 426 o 5:6343ca3eff20 test
385 427 | f
386 428 |
387 429 | o 4:e860deea161a test
388 430 | | e
389 431 | |
390 432 | o 3:055a42cdd887 test
391 433 | | d
392 434 | |
393 435 | o 2:177f92b77385 test
394 436 |/ c
395 437 |
396 438 o 1:d2ae7f538514 test
397 439 | b
398 440 |
399 441 o 0:cb9a9f314b8b test
400 442 a
401 443
402 444 Check it gives error when both --dryrun and --confirm is used:
403 445 $ hg rebase -s 2 -d . --confirm --dry-run
404 446 abort: cannot specify both --confirm and --dry-run
405 447 [255]
406 448 $ hg rebase -s 2 -d . --confirm --abort
407 449 abort: cannot specify both --confirm and --abort
408 450 [255]
409 451 $ hg rebase -s 2 -d . --confirm --continue
410 452 abort: cannot specify both --confirm and --continue
411 453 [255]
412 454
413 455 Test --confirm option when there are no conflicts:
414 456 $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF
415 457 > n
416 458 > EOF
417 459 starting in-memory rebase
418 460 rebasing 2:177f92b77385 "c"
419 461 rebasing 3:055a42cdd887 "d"
420 462 rebasing 4:e860deea161a "e"
421 463 rebase completed successfully
422 464 apply changes (yn)? n
423 465 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
424 466 @ 6:baf10c5166d4 test
425 467 | g
426 468 |
427 469 o 5:6343ca3eff20 test
428 470 | f
429 471 |
430 472 | o 4:e860deea161a test
431 473 | | e
432 474 | |
433 475 | o 3:055a42cdd887 test
434 476 | | d
435 477 | |
436 478 | o 2:177f92b77385 test
437 479 |/ c
438 480 |
439 481 o 1:d2ae7f538514 test
440 482 | b
441 483 |
442 484 o 0:cb9a9f314b8b test
443 485 a
444 486
445 487 $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF
446 488 > y
447 489 > EOF
448 490 starting in-memory rebase
449 491 rebasing 2:177f92b77385 "c"
450 492 rebasing 3:055a42cdd887 "d"
451 493 rebasing 4:e860deea161a "e"
452 494 rebase completed successfully
453 495 apply changes (yn)? y
454 496 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
455 497 o 9:9fd28f55f6dc test
456 498 | e
457 499 |
458 500 o 8:12cbf031f469 test
459 501 | d
460 502 |
461 503 o 7:c83b1da5b1ae test
462 504 | c
463 505 |
464 506 @ 6:baf10c5166d4 test
465 507 | g
466 508 |
467 509 o 5:6343ca3eff20 test
468 510 | f
469 511 |
470 512 | o 4:e860deea161a test
471 513 | | e
472 514 | |
473 515 | o 3:055a42cdd887 test
474 516 | | d
475 517 | |
476 518 | o 2:177f92b77385 test
477 519 |/ c
478 520 |
479 521 o 1:d2ae7f538514 test
480 522 | b
481 523 |
482 524 o 0:cb9a9f314b8b test
483 525 a
484 526
485 527 Test --confirm option when there is a conflict
486 528 $ hg up tip -q
487 529 $ echo ee>e
488 530 $ hg ci --amend -m "conflict with e" -q
489 531 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
490 532 @ 9:906d72f66a59 test
491 533 | conflict with e
492 534 |
493 535 o 8:12cbf031f469 test
494 536 | d
495 537 |
496 538 o 7:c83b1da5b1ae test
497 539 | c
498 540 |
499 541 o 6:baf10c5166d4 test
500 542 | g
501 543 |
502 544 o 5:6343ca3eff20 test
503 545 | f
504 546 |
505 547 | o 4:e860deea161a test
506 548 | | e
507 549 | |
508 550 | o 3:055a42cdd887 test
509 551 | | d
510 552 | |
511 553 | o 2:177f92b77385 test
512 554 |/ c
513 555 |
514 556 o 1:d2ae7f538514 test
515 557 | b
516 558 |
517 559 o 0:cb9a9f314b8b test
518 560 a
519 561
520 562 $ hg rebase -s 4 -d . --keep --confirm
521 563 starting in-memory rebase
522 564 rebasing 4:e860deea161a "e"
523 565 merging e
524 566 hit a merge conflict
525 567 [1]
526 568 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
527 569 @ 9:906d72f66a59 test
528 570 | conflict with e
529 571 |
530 572 o 8:12cbf031f469 test
531 573 | d
532 574 |
533 575 o 7:c83b1da5b1ae test
534 576 | c
535 577 |
536 578 o 6:baf10c5166d4 test
537 579 | g
538 580 |
539 581 o 5:6343ca3eff20 test
540 582 | f
541 583 |
542 584 | o 4:e860deea161a test
543 585 | | e
544 586 | |
545 587 | o 3:055a42cdd887 test
546 588 | | d
547 589 | |
548 590 | o 2:177f92b77385 test
549 591 |/ c
550 592 |
551 593 o 1:d2ae7f538514 test
552 594 | b
553 595 |
554 596 o 0:cb9a9f314b8b test
555 597 a
556 598
557 599 #if execbit
558 600
559 601 Test a metadata-only in-memory merge
560 602 $ cd $TESTTMP
561 603 $ hg init no_exception
562 604 $ cd no_exception
563 605 # Produce the following graph:
564 606 # o 'add +x to foo.txt'
565 607 # | o r1 (adds bar.txt, just for something to rebase to)
566 608 # |/
567 609 # o r0 (adds foo.txt, no +x)
568 610 $ echo hi > foo.txt
569 611 $ hg ci -qAm r0
570 612 $ echo hi > bar.txt
571 613 $ hg ci -qAm r1
572 614 $ hg co -qr ".^"
573 615 $ chmod +x foo.txt
574 616 $ hg ci -qAm 'add +x to foo.txt'
575 617 issue5960: this was raising an AttributeError exception
576 618 $ hg rebase -r . -d 1
577 619 rebasing 2:539b93e77479 "add +x to foo.txt" (tip)
578 620 saved backup bundle to $TESTTMP/no_exception/.hg/strip-backup/*.hg (glob)
579 621 $ hg diff -c tip
580 622 diff --git a/foo.txt b/foo.txt
581 623 old mode 100644
582 624 new mode 100755
583 625
584 626 #endif
General Comments 0
You need to be logged in to leave comments. Login now