Debian Codegraph @

tests/test-rebase-inmemory.t

raw
1 #require symlink execbit
2 $ cat << EOF >> $HGRCPATH
3 > [phases]
4 > publish=False
5 > [extensions]
6 > amend=
7 > rebase=
8 > debugdrawdag=$TESTDIR/drawdag.py
9 > strip=
10 > [rebase]
11 > experimental.inmemory=1
12 > [diff]
13 > git=1
14 > [alias]
15 > tglog = log -G --template "{rev}: {node|short} '{desc}'\n"
16 > EOF
17
18 Rebase a simple DAG:
19 $ hg init repo1
20 $ cd repo1
21 $ hg debugdrawdag <<'EOS'
22 > c b
23 > |/
24 > d
25 > |
26 > a
27 > EOS
28 $ hg up -C a
29 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 $ hg tglog
31 o 3: 814f6bd05178 'c'
32 |
33 | o 2: db0e82a16a62 'b'
34 |/
35 o 1: 02952614a83d 'd'
36 |
37 @ 0: b173517d0057 'a'
38
39 $ hg cat -r 3 c
40 c (no-eol)
41 $ hg cat -r 2 b
42 b (no-eol)
43 $ hg rebase --debug -r b -d c | grep rebasing
44 rebasing in memory
45 rebasing 2:db0e82a16a62 b "b"
46 $ hg tglog
47 o 3: ca58782ad1e4 'b'
48 |
49 o 2: 814f6bd05178 'c'
50 |
51 o 1: 02952614a83d 'd'
52 |
53 @ 0: b173517d0057 'a'
54
55 $ hg cat -r 3 b
56 b (no-eol)
57 $ hg cat -r 2 c
58 c (no-eol)
59 $ cd ..
60
61 Case 2:
62 $ hg init repo2
63 $ cd repo2
64 $ hg debugdrawdag <<'EOS'
65 > c b
66 > |/
67 > d
68 > |
69 > a
70 > EOS
71
72 Add a symlink and executable file:
73 $ hg up -C c
74 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
75 $ ln -s somefile e
76 $ echo f > f
77 $ chmod +x f
78 $ hg add e f
79 $ hg amend -q
80 $ hg up -Cq a
81
82 Write files to the working copy, and ensure they're still there after the rebase
83 $ echo "abc" > a
84 $ ln -s def b
85 $ echo "ghi" > c
86 $ echo "jkl" > d
87 $ echo "mno" > e
88 $ hg tglog
89 o 3: f56b71190a8f 'c'
90 |
91 | o 2: db0e82a16a62 'b'
92 |/
93 o 1: 02952614a83d 'd'
94 |
95 @ 0: b173517d0057 'a'
96
97 $ hg cat -r 3 c
98 c (no-eol)
99 $ hg cat -r 2 b
100 b (no-eol)
101 $ hg cat -r 3 e
102 somefile (no-eol)
103 $ hg rebase --debug -s b -d a | grep rebasing
104 rebasing in memory
105 rebasing 2:db0e82a16a62 b "b"
106 $ hg tglog
107 o 3: fc055c3b4d33 'b'
108 |
109 | o 2: f56b71190a8f 'c'
110 | |
111 | o 1: 02952614a83d 'd'
112 |/
113 @ 0: b173517d0057 'a'
114
115 $ hg cat -r 2 c
116 c (no-eol)
117 $ hg cat -r 3 b
118 b (no-eol)
119 $ hg rebase --debug -s 1 -d 3 | grep rebasing
120 rebasing in memory
121 rebasing 1:02952614a83d d "d"
122 rebasing 2:f56b71190a8f "c"
123 $ hg tglog
124 o 3: 753feb6fd12a 'c'
125 |
126 o 2: 09c044d2cb43 'd'
127 |
128 o 1: fc055c3b4d33 'b'
129 |
130 @ 0: b173517d0057 'a'
131
132 Ensure working copy files are still there:
133 $ cat a
134 abc
135 $ readlink.py b
136 b -> def
137 $ cat e
138 mno
139
140 Ensure symlink and executable files were rebased properly:
141 $ hg up -Cq 3
142 $ readlink.py e
143 e -> somefile
144 $ ls -l f | cut -c -10
145 -rwxr-xr-x
146
147 Rebase the working copy parent
148 $ hg up -C 3
149 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
150 $ hg rebase -r 3 -d 0 --debug | grep rebasing
151 rebasing in memory
152 rebasing 3:753feb6fd12a tip "c"
153 $ hg tglog
154 @ 3: 844a7de3e617 'c'
155 |
156 | o 2: 09c044d2cb43 'd'
157 | |
158 | o 1: fc055c3b4d33 'b'
159 |/
160 o 0: b173517d0057 'a'
161
162
163 Test reporting of path conflicts
164
165 $ hg rm a
166 $ mkdir a
167 $ touch a/a
168 $ hg ci -Am "a/a"
169 adding a/a
170 $ hg tglog
171 @ 4: daf7dfc139cb 'a/a'
172 |
173 o 3: 844a7de3e617 'c'
174 |
175 | o 2: 09c044d2cb43 'd'
176 | |
177 | o 1: fc055c3b4d33 'b'
178 |/
179 o 0: b173517d0057 'a'
180
181 $ hg rebase -r . -d 2
182 rebasing 4:daf7dfc139cb tip "a/a"
183 saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/daf7dfc139cb-fdbfcf4f-rebase.hg
184
185 $ hg tglog
186 @ 4: c6ad37a4f250 'a/a'
187 |
188 | o 3: 844a7de3e617 'c'
189 | |
190 o | 2: 09c044d2cb43 'd'
191 | |
192 o | 1: fc055c3b4d33 'b'
193 |/
194 o 0: b173517d0057 'a'
195
196 $ echo foo > foo
197 $ hg ci -Aqm "added foo"
198 $ hg up '.^'
199 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
200 $ echo bar > bar
201 $ hg ci -Aqm "added bar"
202 $ hg rm a/a
203 $ echo a > a
204 $ hg ci -Aqm "added a back!"
205 $ hg tglog
206 @ 7: 855e9797387e 'added a back!'
207 |
208 o 6: d14530e5e3e6 'added bar'
209 |
210 | o 5: 9b94b9373deb 'added foo'
211 |/
212 o 4: c6ad37a4f250 'a/a'
213 |
214 | o 3: 844a7de3e617 'c'
215 | |
216 o | 2: 09c044d2cb43 'd'
217 | |
218 o | 1: fc055c3b4d33 'b'
219 |/
220 o 0: b173517d0057 'a'
221
222 $ hg rebase -r . -d 5
223 rebasing 7:855e9797387e tip "added a back!"
224 saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/855e9797387e-81ee4c5d-rebase.hg
225
226 $ hg tglog
227 @ 7: bb3f02be2688 'added a back!'
228 |
229 | o 6: d14530e5e3e6 'added bar'
230 | |
231 o | 5: 9b94b9373deb 'added foo'
232 |/
233 o 4: c6ad37a4f250 'a/a'
234 |
235 | o 3: 844a7de3e617 'c'
236 | |
237 o | 2: 09c044d2cb43 'd'
238 | |
239 o | 1: fc055c3b4d33 'b'
240 |/
241 o 0: b173517d0057 'a'
242
243 $ mkdir -p c/subdir
244 $ echo c > c/subdir/file.txt
245 $ hg add c/subdir/file.txt
246 $ hg ci -m 'c/subdir/file.txt'
247 $ hg rebase -r . -d 3 -n
248 starting dry-run rebase; repository will not be changed
249 rebasing 8:e147e6e3c490 tip "c/subdir/file.txt"
250 abort: error: 'c/subdir/file.txt' conflicts with file 'c' in 3.
251 [255]
252 FIXME: shouldn't need this, but when we hit path conflicts in dryrun mode, we
253 don't clean up rebasestate.
254 $ hg rebase --abort
255 rebase aborted
256 $ hg rebase -r 3 -d . -n
257 starting dry-run rebase; repository will not be changed
258 rebasing 3:844a7de3e617 "c"
259 abort: error: file 'c' cannot be written because 'c/' is a directory in e147e6e3c490 (containing 1 entries: c/subdir/file.txt)
260 [255]
261
262 $ cd ..
263
264 Test path auditing (issue5818)
265
266 $ mkdir lib_
267 $ ln -s lib_ lib
268 $ hg init repo
269 $ cd repo
270 $ mkdir -p ".$TESTTMP/lib"
271 $ touch ".$TESTTMP/lib/a"
272 $ hg add ".$TESTTMP/lib/a"
273 $ hg ci -m 'a'
274
275 $ touch ".$TESTTMP/lib/b"
276 $ hg add ".$TESTTMP/lib/b"
277 $ hg ci -m 'b'
278
279 $ hg up -q '.^'
280 $ touch ".$TESTTMP/lib/c"
281 $ hg add ".$TESTTMP/lib/c"
282 $ hg ci -m 'c'
283 created new head
284 $ hg rebase -s 1 -d .
285 rebasing 1:* "b" (glob)
286 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-rebase.hg (glob)
287 $ cd ..
288
289 Test dry-run rebasing
290
291 $ hg init repo3
292 $ cd repo3
293 $ echo a>a
294 $ hg ci -Aqma
295 $ echo b>b
296 $ hg ci -Aqmb
297 $ echo c>c
298 $ hg ci -Aqmc
299 $ echo d>d
300 $ hg ci -Aqmd
301 $ echo e>e
302 $ hg ci -Aqme
303
304 $ hg up 1 -q
305 $ echo f>f
306 $ hg ci -Amf
307 adding f
308 created new head
309 $ echo g>g
310 $ hg ci -Aqmg
311 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
312 @ 6:baf10c5166d4 test
313 | g
314 |
315 o 5:6343ca3eff20 test
316 | f
317 |
318 | o 4:e860deea161a test
319 | | e
320 | |
321 | o 3:055a42cdd887 test
322 | | d
323 | |
324 | o 2:177f92b77385 test
325 |/ c
326 |
327 o 1:d2ae7f538514 test
328 | b
329 |
330 o 0:cb9a9f314b8b test
331 a
332
333 Make sure it throws error while passing --continue or --abort with --dry-run
334 $ hg rebase -s 2 -d 6 -n --continue
335 abort: cannot specify both --continue and --dry-run
336 [10]
337 $ hg rebase -s 2 -d 6 -n --abort
338 abort: cannot specify both --abort and --dry-run
339 [10]
340
341 When nothing to rebase
342 $ hg reb -r . -d '.^' -n
343 starting dry-run rebase; repository will not be changed
344 nothing to rebase
345 [1]
346
347 Check dryrun gives correct results when there is no conflict in rebasing
348 $ hg rebase -s 2 -d 6 -n
349 starting dry-run rebase; repository will not be changed
350 rebasing 2:177f92b77385 "c"
351 rebasing 3:055a42cdd887 "d"
352 rebasing 4:e860deea161a "e"
353 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
354
355 $ hg diff
356 $ hg status
357
358 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
359 @ 6:baf10c5166d4 test
360 | g
361 |
362 o 5:6343ca3eff20 test
363 | f
364 |
365 | o 4:e860deea161a test
366 | | e
367 | |
368 | o 3:055a42cdd887 test
369 | | d
370 | |
371 | o 2:177f92b77385 test
372 |/ c
373 |
374 o 1:d2ae7f538514 test
375 | b
376 |
377 o 0:cb9a9f314b8b test
378 a
379
380 Check dryrun working with --collapse when there is no conflict
381 $ hg rebase -s 2 -d 6 -n --collapse
382 starting dry-run rebase; repository will not be changed
383 rebasing 2:177f92b77385 "c"
384 rebasing 3:055a42cdd887 "d"
385 rebasing 4:e860deea161a "e"
386 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
387
388 Check dryrun gives correct results when there is conflict in rebasing
389 Make a conflict:
390 $ hg up 6 -q
391 $ echo conflict>e
392 $ hg ci -Aqm "conflict with e"
393 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
394 @ 7:d2c195b28050 test
395 | conflict with e
396 |
397 o 6:baf10c5166d4 test
398 | g
399 |
400 o 5:6343ca3eff20 test
401 | f
402 |
403 | o 4:e860deea161a test
404 | | e
405 | |
406 | o 3:055a42cdd887 test
407 | | d
408 | |
409 | o 2:177f92b77385 test
410 |/ c
411 |
412 o 1:d2ae7f538514 test
413 | b
414 |
415 o 0:cb9a9f314b8b test
416 a
417
418 $ hg rebase -s 2 -d 7 -n
419 starting dry-run rebase; repository will not be changed
420 rebasing 2:177f92b77385 "c"
421 rebasing 3:055a42cdd887 "d"
422 rebasing 4:e860deea161a "e"
423 merging e
424 hit a merge conflict
425 [1]
426 $ hg diff
427 $ hg status
428 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
429 @ 7:d2c195b28050 test
430 | conflict with e
431 |
432 o 6:baf10c5166d4 test
433 | g
434 |
435 o 5:6343ca3eff20 test
436 | f
437 |
438 | o 4:e860deea161a test
439 | | e
440 | |
441 | o 3:055a42cdd887 test
442 | | d
443 | |
444 | o 2:177f92b77385 test
445 |/ c
446 |
447 o 1:d2ae7f538514 test
448 | b
449 |
450 o 0:cb9a9f314b8b test
451 a
452
453 Check dryrun working with --collapse when there is conflicts
454 $ hg rebase -s 2 -d 7 -n --collapse
455 starting dry-run rebase; repository will not be changed
456 rebasing 2:177f92b77385 "c"
457 rebasing 3:055a42cdd887 "d"
458 rebasing 4:e860deea161a "e"
459 merging e
460 hit a merge conflict
461 [1]
462
463 In-memory rebase that fails due to merge conflicts
464
465 $ hg rebase -s 2 -d 7
466 rebasing 2:177f92b77385 "c"
467 rebasing 3:055a42cdd887 "d"
468 rebasing 4:e860deea161a "e"
469 merging e
470 hit merge conflicts; rebasing that commit again in the working copy
471 merging e
472 warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
473 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
474 [240]
475 $ hg rebase --abort
476 saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/c1e524d4287c-f91f82e1-backup.hg
477 rebase aborted
478
479 Retrying without in-memory merge won't lose working copy changes
480 $ cd ..
481 $ hg clone repo3 repo3-dirty -q
482 $ cd repo3-dirty
483 $ echo dirty > a
484 $ hg rebase -s 2 -d 7
485 rebasing 2:177f92b77385 "c"
486 rebasing 3:055a42cdd887 "d"
487 rebasing 4:e860deea161a "e"
488 merging e
489 hit merge conflicts; rebasing that commit again in the working copy
490 transaction abort!
491 rollback completed
492 abort: uncommitted changes
493 [20]
494 $ cat a
495 dirty
496 $ hg status -v
497 M a
498
499 Retrying without in-memory merge won't lose merge state
500 $ cd ..
501 $ hg clone repo3 repo3-merge-state -q
502 $ cd repo3-merge-state
503 $ hg merge 4
504 merging e
505 warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
506 2 files updated, 0 files merged, 0 files removed, 1 files unresolved
507 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
508 [1]
509 $ hg resolve -l
510 U e
511 $ hg rebase -s 2 -d 7
512 abort: outstanding uncommitted merge
513 (use 'hg commit' or 'hg merge --abort')
514 [20]
515 $ hg resolve -l
516 U e
517
518 ==========================
519 Test for --confirm option|
520 ==========================
521 $ cd ..
522 $ hg clone repo3 repo4 -q
523 $ cd repo4
524 $ hg strip 7 -q
525 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
526 @ 6:baf10c5166d4 test
527 | g
528 |
529 o 5:6343ca3eff20 test
530 | f
531 |
532 | o 4:e860deea161a test
533 | | e
534 | |
535 | o 3:055a42cdd887 test
536 | | d
537 | |
538 | o 2:177f92b77385 test
539 |/ c
540 |
541 o 1:d2ae7f538514 test
542 | b
543 |
544 o 0:cb9a9f314b8b test
545 a
546
547 Check it gives error when both --dryrun and --confirm is used:
548 $ hg rebase -s 2 -d . --confirm --dry-run
549 abort: cannot specify both --confirm and --dry-run
550 [10]
551 $ hg rebase -s 2 -d . --confirm --abort
552 abort: cannot specify both --abort and --confirm
553 [10]
554 $ hg rebase -s 2 -d . --confirm --continue
555 abort: cannot specify both --continue and --confirm
556 [10]
557
558 Test --confirm option when there are no conflicts:
559 $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF
560 > n
561 > EOF
562 starting in-memory rebase
563 rebasing 2:177f92b77385 "c"
564 rebasing 3:055a42cdd887 "d"
565 rebasing 4:e860deea161a "e"
566 rebase completed successfully
567 apply changes (yn)? n
568 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
569 @ 6:baf10c5166d4 test
570 | g
571 |
572 o 5:6343ca3eff20 test
573 | f
574 |
575 | o 4:e860deea161a test
576 | | e
577 | |
578 | o 3:055a42cdd887 test
579 | | d
580 | |
581 | o 2:177f92b77385 test
582 |/ c
583 |
584 o 1:d2ae7f538514 test
585 | b
586 |
587 o 0:cb9a9f314b8b test
588 a
589
590 $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF
591 > y
592 > EOF
593 starting in-memory rebase
594 rebasing 2:177f92b77385 "c"
595 rebasing 3:055a42cdd887 "d"
596 rebasing 4:e860deea161a "e"
597 rebase completed successfully
598 apply changes (yn)? y
599 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
600 o 9:9fd28f55f6dc test
601 | e
602 |
603 o 8:12cbf031f469 test
604 | d
605 |
606 o 7:c83b1da5b1ae test
607 | c
608 |
609 @ 6:baf10c5166d4 test
610 | g
611 |
612 o 5:6343ca3eff20 test
613 | f
614 |
615 | o 4:e860deea161a test
616 | | e
617 | |
618 | o 3:055a42cdd887 test
619 | | d
620 | |
621 | o 2:177f92b77385 test
622 |/ c
623 |
624 o 1:d2ae7f538514 test
625 | b
626 |
627 o 0:cb9a9f314b8b test
628 a
629
630 Test --confirm option when there is a conflict
631 $ hg up tip -q
632 $ echo ee>e
633 $ hg ci --amend -m "conflict with e" -q
634 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
635 @ 9:906d72f66a59 test
636 | conflict with e
637 |
638 o 8:12cbf031f469 test
639 | d
640 |
641 o 7:c83b1da5b1ae test
642 | c
643 |
644 o 6:baf10c5166d4 test
645 | g
646 |
647 o 5:6343ca3eff20 test
648 | f
649 |
650 | o 4:e860deea161a test
651 | | e
652 | |
653 | o 3:055a42cdd887 test
654 | | d
655 | |
656 | o 2:177f92b77385 test
657 |/ c
658 |
659 o 1:d2ae7f538514 test
660 | b
661 |
662 o 0:cb9a9f314b8b test
663 a
664
665 $ hg rebase -s 4 -d . --keep --confirm
666 starting in-memory rebase
667 rebasing 4:e860deea161a "e"
668 merging e
669 hit a merge conflict
670 [1]
671 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
672 @ 9:906d72f66a59 test
673 | conflict with e
674 |
675 o 8:12cbf031f469 test
676 | d
677 |
678 o 7:c83b1da5b1ae test
679 | c
680 |
681 o 6:baf10c5166d4 test
682 | g
683 |
684 o 5:6343ca3eff20 test
685 | f
686 |
687 | o 4:e860deea161a test
688 | | e
689 | |
690 | o 3:055a42cdd887 test
691 | | d
692 | |
693 | o 2:177f92b77385 test
694 |/ c
695 |
696 o 1:d2ae7f538514 test
697 | b
698 |
699 o 0:cb9a9f314b8b test
700 a
701
702 Test a metadata-only in-memory merge
703 $ cd $TESTTMP
704 $ hg init no_exception
705 $ cd no_exception
706 # Produce the following graph:
707 # o 'add +x to foo.txt'
708 # | o r1 (adds bar.txt, just for something to rebase to)
709 # |/
710 # o r0 (adds foo.txt, no +x)
711 $ echo hi > foo.txt
712 $ hg ci -qAm r0
713 $ echo hi > bar.txt
714 $ hg ci -qAm r1
715 $ hg co -qr ".^"
716 $ chmod +x foo.txt
717 $ hg ci -qAm 'add +x to foo.txt'
718 issue5960: this was raising an AttributeError exception
719 $ hg rebase -r . -d 1
720 rebasing 2:539b93e77479 tip "add +x to foo.txt"
721 saved backup bundle to $TESTTMP/no_exception/.hg/strip-backup/*.hg (glob)
722 $ hg diff -c tip
723 diff --git a/foo.txt b/foo.txt
724 old mode 100644
725 new mode 100755
726
727 Test rebasing a commit with copy information, but no content changes
728
729 $ cd ..
730 $ hg clone -q repo1 merge-and-rename
731 $ cd merge-and-rename
732 $ cat << EOF >> .hg/hgrc
733 > [experimental]
734 > evolution.createmarkers=True
735 > evolution.allowunstable=True
736 > EOF
737 $ hg co -q 1
738 $ hg mv d e
739 $ hg ci -qm 'rename d to e'
740 $ hg co -q 3
741 $ hg merge -q 4
742 $ hg ci -m 'merge'
743 $ hg co -q 2
744 $ mv d e
745 $ hg addremove -qs 0
746 $ hg ci -qm 'untracked rename of d to e'
747 $ hg debugobsolete -q `hg log -T '{node}' -r 4` `hg log -T '{node}' -r .`
748 1 new orphan changesets
749 $ hg tglog
750 @ 6: 676538af172d 'untracked rename of d to e'
751 |
752 | * 5: 574d92ad16fc 'merge'
753 | |\
754 | | x 4: 2c8b5dad7956 'rename d to e'
755 | | |
756 | o | 3: ca58782ad1e4 'b'
757 |/ /
758 o / 2: 814f6bd05178 'c'
759 |/
760 o 1: 02952614a83d 'd'
761 |
762 o 0: b173517d0057 'a'
763
764 $ hg rebase -b 5 -d tip
765 rebasing 3:ca58782ad1e4 "b"
766 rebasing 5:574d92ad16fc "merge"
767 note: not rebasing 5:574d92ad16fc "merge", its destination already has all its changes
768
769 $ cd ..
770
771 Test rebasing a commit with copy information
772
773 $ hg init rebase-rename
774 $ cd rebase-rename
775 $ echo a > a
776 $ hg ci -Aqm 'add a'
777 $ echo a2 > a
778 $ hg ci -m 'modify a'
779 $ hg co -q 0
780 $ hg mv a b
781 $ hg ci -qm 'rename a to b'
782 $ hg rebase -d 1
783 rebasing 2:b977edf6f839 tip "rename a to b"
784 merging a and b to b
785 saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/b977edf6f839-0864f570-rebase.hg
786 $ hg st --copies --change .
787 A b
788 a
789 R a
790 $ cd ..
791
792 Test rebasing a commit with copy information, where the target is empty
793
794 $ hg init rebase-rename-empty
795 $ cd rebase-rename-empty
796 $ echo a > a
797 $ hg ci -Aqm 'add a'
798 $ cat > a
799 $ hg ci -m 'make a empty'
800 $ hg co -q 0
801 $ hg mv a b
802 $ hg ci -qm 'rename a to b'
803 $ hg rebase -d 1
804 rebasing 2:b977edf6f839 tip "rename a to b"
805 merging a and b to b
806 saved backup bundle to $TESTTMP/rebase-rename-empty/.hg/strip-backup/b977edf6f839-0864f570-rebase.hg
807 $ hg st --copies --change .
808 A b
809 a
810 R a
811 $ cd ..
812 Rebase across a copy with --collapse
813
814 $ hg init rebase-rename-collapse
815 $ cd rebase-rename-collapse
816 $ echo a > a
817 $ hg ci -Aqm 'add a'
818 $ hg mv a b
819 $ hg ci -m 'rename a to b'
820 $ hg co -q 0
821 $ echo a2 > a
822 $ hg ci -qm 'modify a'
823 $ hg rebase -r . -d 1 --collapse
824 rebasing 2:41c4ea50d4cf tip "modify a"
825 merging b and a to b
826 saved backup bundle to $TESTTMP/rebase-rename-collapse/.hg/strip-backup/41c4ea50d4cf-b90b7994-rebase.hg
827 $ cd ..
828
829 Test rebasing when the file we are merging in destination is empty
830
831 $ hg init test
832 $ cd test
833 $ echo a > foo
834 $ hg ci -Aqm 'added a to foo'
835
836 $ rm foo
837 $ touch foo
838 $ hg di
839 diff --git a/foo b/foo
840 --- a/foo
841 +++ b/foo
842 @@ -1,1 +0,0 @@
843 -a
844
845 $ hg ci -m "make foo an empty file"
846
847 $ hg up '.^'
848 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
849 $ echo b > foo
850 $ hg di
851 diff --git a/foo b/foo
852 --- a/foo
853 +++ b/foo
854 @@ -1,1 +1,1 @@
855 -a
856 +b
857 $ hg ci -m "add b to foo"
858 created new head
859
860 $ hg rebase -r . -d 1 --config ui.merge=internal:merge3
861 rebasing 2:fb62b706688e tip "add b to foo"
862 merging foo
863 hit merge conflicts; rebasing that commit again in the working copy
864 merging foo
865 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
866 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
867 [240]
868
869 $ cd $TESTTMP
870
871 Test rebasing when we're in the middle of a rebase already
872 $ hg init test_issue6214
873 $ cd test_issue6214
874 $ echo r0 > r0
875 $ hg ci -qAm 'r0'
876 $ echo hi > foo
877 $ hg ci -qAm 'hi from foo'
878 $ hg co -q '.^'
879 $ echo bye > foo
880 $ hg ci -qAm 'bye from foo'
881 $ hg co -q '.^'
882 $ echo unrelated > some_other_file
883 $ hg ci -qAm 'some unrelated changes'
884 $ hg log -G -T'{rev}: {desc}\n{files%"{file}\n"}'
885 @ 3: some unrelated changes
886 | some_other_file
887 | o 2: bye from foo
888 |/ foo
889 | o 1: hi from foo
890 |/ foo
891 o 0: r0
892 r0
893 $ hg rebase -r 2 -d 1 -t:merge3
894 rebasing 2:b4d249fbf8dd "bye from foo"
895 merging foo
896 hit merge conflicts; rebasing that commit again in the working copy
897 merging foo
898 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
899 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
900 [240]
901 $ hg rebase -r 3 -d 1 -t:merge3
902 abort: rebase in progress
903 (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
904 [20]
905 $ hg resolve --list
906 U foo
907 $ hg resolve --all --re-merge -t:other
908 (no more unresolved files)
909 continue: hg rebase --continue
910 $ hg rebase --continue
911 rebasing 2:b4d249fbf8dd "bye from foo"
912 saved backup bundle to $TESTTMP/test_issue6214/.hg/strip-backup/b4d249fbf8dd-299ec25c-rebase.hg
913 $ hg log -G -T'{rev}: {desc}\n{files%"{file}\n"}'
914 o 3: bye from foo
915 | foo
916 | @ 2: some unrelated changes
917 | | some_other_file
918 o | 1: hi from foo
919 |/ foo
920 o 0: r0
921 r0
922
923 $ cd ..
924
925 Changesets that become empty should not be committed. Merges are not empty by
926 definition.
927
928 $ hg init keep_merge
929 $ cd keep_merge
930 $ echo base > base; hg add base; hg ci -m base
931 $ echo test > test; hg add test; hg ci -m a
932 $ hg up 0 -q
933 $ echo test > test; hg add test; hg ci -m b -q
934 $ hg up 0 -q
935 $ echo test > test; hg add test; hg ci -m c -q
936 $ hg up 1 -q
937 $ hg merge 2 -q
938 $ hg ci -m merge
939 $ hg up null -q
940 $ hg tglog
941 o 4: 59c8292117b1 'merge'
942 |\
943 | | o 3: 531f80391e4a 'c'
944 | | |
945 | o | 2: 0194f1db184a 'b'
946 | |/
947 o / 1: 6f252845ea45 'a'
948 |/
949 o 0: d20a80d4def3 'base'
950
951 $ hg rebase -s 2 -d 3
952 rebasing 2:0194f1db184a "b"
953 note: not rebasing 2:0194f1db184a "b", its destination already has all its changes
954 rebasing 4:59c8292117b1 tip "merge"
955 saved backup bundle to $TESTTMP/keep_merge/.hg/strip-backup/0194f1db184a-aee31d03-rebase.hg
956 $ hg tglog
957 o 3: 506e2454484b 'merge'
958 |\
959 | o 2: 531f80391e4a 'c'
960 | |
961 o | 1: 6f252845ea45 'a'
962 |/
963 o 0: d20a80d4def3 'base'
964
965
966 Test that update_hash_refs works.
967 $ hg co 0
968 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
969 $ echo update_hash_refs > update_hash_refs
970 $ hg add update_hash_refs
971 $ hg ci -m 'this will change hash'
972 created new head
973 $ echo changed >> update_hash_refs
974 $ hg ci -m "this starts as the child of `hg log -r . -T'{node|short}'` but not 506e2454484b. Also, ffffffffffffffff"
975 $ hg tglog
976 @ 5: a8b42cbbde83 'this starts as the child of 98789aa60148 but not 506e2454484b. Also, ffffffffffffffff'
977 |
978 o 4: 98789aa60148 'this will change hash'
979 |
980 | o 3: 506e2454484b 'merge'
981 | |\
982 +---o 2: 531f80391e4a 'c'
983 | |
984 | o 1: 6f252845ea45 'a'
985 |/
986 o 0: d20a80d4def3 'base'
987
988 $ hg rebase -r '.^::' -d 3
989 rebasing 4:98789aa60148 "this will change hash"
990 rebasing 5:a8b42cbbde83 tip "this starts as the child of 98789aa60148 but not 506e2454484b. Also, ffffffffffffffff"
991 saved backup bundle to $TESTTMP/keep_merge/.hg/strip-backup/98789aa60148-da3f4c2c-rebase.hg
992 $ hg tglog
993 @ 5: 0fd2912e6cc1 'this starts as the child of c16c25696fe7 but not 506e2454484b. Also, ffffffffffffffff'
994 |
995 o 4: c16c25696fe7 'this will change hash'
996 |
997 o 3: 506e2454484b 'merge'
998 |\
999 | o 2: 531f80391e4a 'c'
1000 | |
1001 o | 1: 6f252845ea45 'a'
1002 |/
1003 o 0: d20a80d4def3 'base'
1004
1005
1006 Add an explicit test for rewrite_hash_refs when the detected prefix is
1007 ambiguous. Here's the super low-tech way I found this collision, if the hashing
1008 scheme ever changes:
1009 # hg init
1010 # echo test0 > test
1011 # hg ci -qAm 'test0' -u 'test' -d '0 0'
1012 # i=1
1013 # while [[ $(chg log -r . -T'{shortest(node, 6)}' | wc -c) -eq 6 ]]; do
1014 # chg co -r 0000000000
1015 # echo "test$i" > test
1016 # chg ci -qAm "test$i" -u test -d '0 0'
1017 # (( ++i ))
1018 # done
1019 $ hg co -q 0000000000
1020 $ echo test5281 > test
1021 $ hg ci -qAm 'test5281'
1022 $ hg co -q 000000000
1023 $ echo test9912 > test
1024 $ hg ci -qAm 'test9912'
1025 $ hg co -q 4
1026 $ echo contents > some_file
1027 $ hg ci -qAm 'The previous two (parentless) commits had a hash prefix of b04363. Check that rewrite_hash_refs will not fail because of that.'
1028 $ hg rebase -r . -d 5
1029 rebasing 8:5c4cdabf5769 tip "The previous two (parentless) commits had a hash prefix of b04363. Check that rewrite_hash_refs will not fail because of that."
1030 saved backup bundle to $TESTTMP/keep_merge/.hg/strip-backup/5c4cdabf5769-335e1828-rebase.hg
1031
1032 $ cd ..
1033
1034 Test (virtual) working directory without changes, created by merge conflict
1035 resolution. There was a regression where the file was incorrectly detected as
1036 changed although the file contents were the same as in the parent.
1037
1038 $ hg init nofilechanges
1039 $ cd nofilechanges
1040 $ echo a > a; hg add a; hg ci -m a
1041 $ echo foo > test; hg add test; hg ci -m b
1042 $ hg up 0 -q
1043 $ echo bar > test; hg add test; hg ci -m c
1044 created new head
1045 $ hg rebase -d 2 -d 1 --tool :local
1046 rebasing 2:ca2749322ee5 tip "c"
1047 note: not rebasing 2:ca2749322ee5 tip "c", its destination already has all its changes
1048 saved backup bundle to $TESTTMP/nofilechanges/.hg/strip-backup/ca2749322ee5-6dc7e94b-rebase.hg