Debian Codegraph @

tests/test-transplant.t

raw
1 #testcases commandmode continueflag
2 $ cat <<EOF >> $HGRCPATH
3 > [extensions]
4 > transplant=
5 > graphlog=
6 > EOF
7
8 #if continueflag
9 $ cat >> $HGRCPATH <<EOF
10 > [alias]
11 > continue = transplant --continue
12 > EOF
13 #endif
14
15 $ hg init t
16 $ cd t
17 $ hg transplant
18 abort: no source URL, branch revision, or revision list provided
19 [255]
20 $ hg transplant --continue --all
21 abort: cannot specify both --continue and --all
22 [10]
23 $ hg transplant --stop --all
24 abort: cannot specify both --stop and --all
25 [10]
26 $ hg transplant --all tip
27 abort: --all requires a branch revision
28 [255]
29 $ hg transplant --all --branch default tip
30 abort: --all is incompatible with a revision list
31 [255]
32 $ echo r1 > r1
33 $ hg ci -Amr1 -d'0 0'
34 adding r1
35 $ hg co -q null
36 $ hg transplant tip
37 abort: no revision checked out
38 [255]
39 $ hg up -q
40 $ echo r2 > r2
41 $ hg ci -Amr2 -d'1 0'
42 adding r2
43 $ hg up 0
44 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
45
46 $ echo b1 > b1
47 $ hg ci -Amb1 -d '0 0'
48 adding b1
49 created new head
50 $ hg merge 1
51 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
52 (branch merge, don't forget to commit)
53 $ hg transplant 1
54 abort: outstanding uncommitted merge
55 (use 'hg commit' or 'hg merge --abort')
56 [20]
57 $ hg up -qC tip
58 $ echo b0 > b1
59 $ hg transplant 1
60 abort: uncommitted changes
61 [20]
62 $ hg up -qC tip
63 $ echo b2 > b2
64 $ hg ci -Amb2 -d '1 0'
65 adding b2
66 $ echo b3 > b3
67 $ hg ci -Amb3 -d '2 0'
68 adding b3
69
70 $ hg log --template '{rev} {parents} {desc}\n'
71 4 b3
72 3 b2
73 2 0:17ab29e464c6 b1
74 1 r2
75 0 r1
76
77 $ hg clone . ../rebase
78 updating to branch default
79 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 $ hg init ../emptydest
81 $ cd ../emptydest
82 $ hg transplant --source=../t > /dev/null
83 $ cd ../rebase
84
85 $ hg up -C 1
86 1 files updated, 0 files merged, 3 files removed, 0 files unresolved
87
88 rebase b onto r1
89 (this also tests that editor is not invoked if '--edit' is not specified)
90
91 $ HGEDITOR=cat hg transplant -a -b tip
92 applying 37a1297eb21b
93 37a1297eb21b transplanted to e234d668f844
94 applying 722f4667af76
95 722f4667af76 transplanted to 539f377d78df
96 applying a53251cdf717
97 a53251cdf717 transplanted to ffd6818a3975
98 $ hg log --template '{rev} {parents} {desc}\n'
99 7 b3
100 6 b2
101 5 1:d11e3596cc1a b1
102 4 b3
103 3 b2
104 2 0:17ab29e464c6 b1
105 1 r2
106 0 r1
107
108 test format of transplant_source
109
110 $ hg log -r7 --debug | grep transplant_source
111 extra: transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z
112 $ hg log -r7 -T '{extras}\n'
113 branch=defaulttransplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z
114 $ hg log -r7 -T '{join(extras, " ")}\n'
115 branch=default transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z
116
117 test transplanted revset
118
119 $ hg log -r 'transplanted()' --template '{rev} {parents} {desc}\n'
120 5 1:d11e3596cc1a b1
121 6 b2
122 7 b3
123 $ hg log -r 'transplanted(head())' --template '{rev} {parents} {desc}\n'
124 7 b3
125 $ hg help revisions.transplanted
126 "transplanted([set])"
127 Transplanted changesets in set, or all transplanted changesets.
128
129
130 test transplanted keyword
131
132 $ hg log --template '{rev} {transplanted}\n'
133 7 a53251cdf717679d1907b289f991534be05c997a
134 6 722f4667af767100cb15b6a79324bf8abbfe1ef4
135 5 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21
136 4
137 3
138 2
139 1
140 0
141
142 test destination() revset predicate with a transplant of a transplant; new
143 clone so subsequent rollback isn't affected
144 (this also tests that editor is invoked if '--edit' is specified)
145
146 $ hg clone -q . ../destination
147 $ cd ../destination
148 $ hg up -Cq 0
149 $ hg branch -q b4
150 $ hg ci -qm "b4"
151 $ hg status --rev "7^1" --rev 7
152 A b3
153 $ cat > $TESTTMP/checkeditform.sh <<EOF
154 > env | grep HGEDITFORM
155 > true
156 > EOF
157 $ cat > $TESTTMP/checkeditform-n-cat.sh <<EOF
158 > env | grep HGEDITFORM
159 > cat \$*
160 > EOF
161 $ HGEDITOR="sh $TESTTMP/checkeditform-n-cat.sh" hg transplant --edit 7
162 applying ffd6818a3975
163 HGEDITFORM=transplant.normal
164 b3
165
166
167 HG: Enter commit message. Lines beginning with 'HG:' are removed.
168 HG: Leave message empty to abort commit.
169 HG: --
170 HG: user: test
171 HG: branch 'b4'
172 HG: added b3
173 ffd6818a3975 transplanted to 502236fa76bb
174
175
176 $ hg log -r 'destination()'
177 changeset: 5:e234d668f844
178 parent: 1:d11e3596cc1a
179 user: test
180 date: Thu Jan 01 00:00:00 1970 +0000
181 summary: b1
182
183 changeset: 6:539f377d78df
184 user: test
185 date: Thu Jan 01 00:00:01 1970 +0000
186 summary: b2
187
188 changeset: 7:ffd6818a3975
189 user: test
190 date: Thu Jan 01 00:00:02 1970 +0000
191 summary: b3
192
193 changeset: 9:502236fa76bb
194 branch: b4
195 tag: tip
196 user: test
197 date: Thu Jan 01 00:00:02 1970 +0000
198 summary: b3
199
200 $ hg log -r 'destination(a53251cdf717)'
201 changeset: 7:ffd6818a3975
202 user: test
203 date: Thu Jan 01 00:00:02 1970 +0000
204 summary: b3
205
206 changeset: 9:502236fa76bb
207 branch: b4
208 tag: tip
209 user: test
210 date: Thu Jan 01 00:00:02 1970 +0000
211 summary: b3
212
213
214 test subset parameter in reverse order
215 $ hg log -r 'reverse(all()) and destination(a53251cdf717)'
216 changeset: 9:502236fa76bb
217 branch: b4
218 tag: tip
219 user: test
220 date: Thu Jan 01 00:00:02 1970 +0000
221 summary: b3
222
223 changeset: 7:ffd6818a3975
224 user: test
225 date: Thu Jan 01 00:00:02 1970 +0000
226 summary: b3
227
228
229 back to the original dir
230 $ cd ../rebase
231
232 rollback the transplant
233 $ hg rollback
234 repository tip rolled back to revision 4 (undo transplant)
235 working directory now based on revision 1
236 $ hg tip -q
237 4:a53251cdf717
238 $ hg parents -q
239 1:d11e3596cc1a
240 $ hg status
241 ? b1
242 ? b2
243 ? b3
244
245 $ hg clone ../t ../prune
246 updating to branch default
247 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
248 $ cd ../prune
249
250 $ hg up -C 1
251 1 files updated, 0 files merged, 3 files removed, 0 files unresolved
252
253 rebase b onto r1, skipping b2
254
255 $ hg transplant -a -b tip -p 3
256 applying 37a1297eb21b
257 37a1297eb21b transplanted to e234d668f844
258 applying a53251cdf717
259 a53251cdf717 transplanted to 7275fda4d04f
260 $ hg log --template '{rev} {parents} {desc}\n'
261 6 b3
262 5 1:d11e3596cc1a b1
263 4 b3
264 3 b2
265 2 0:17ab29e464c6 b1
266 1 r2
267 0 r1
268
269 test same-parent transplant with --log
270
271 $ hg clone -r 1 ../t ../sameparent
272 adding changesets
273 adding manifests
274 adding file changes
275 added 2 changesets with 2 changes to 2 files
276 new changesets 17ab29e464c6:d11e3596cc1a
277 updating to branch default
278 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
279 $ cd ../sameparent
280 $ hg transplant --log -s ../prune 5
281 searching for changes
282 applying e234d668f844
283 e234d668f844 transplanted to e07aea8ecf9c
284 $ hg log --template '{rev} {parents} {desc}\n'
285 2 b1
286 (transplanted from e234d668f844e1b1a765f01db83a32c0c7bfa170)
287 1 r2
288 0 r1
289 remote transplant, and also test that transplant doesn't break with
290 format-breaking diffopts
291
292 $ hg clone -r 1 ../t ../remote
293 adding changesets
294 adding manifests
295 adding file changes
296 added 2 changesets with 2 changes to 2 files
297 new changesets 17ab29e464c6:d11e3596cc1a
298 updating to branch default
299 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
300 $ cd ../remote
301 $ hg --config diff.noprefix=True transplant --log -s ../t 2 4
302 searching for changes
303 applying 37a1297eb21b
304 37a1297eb21b transplanted to c19cf0ccb069
305 applying a53251cdf717
306 a53251cdf717 transplanted to f7fe5bf98525
307 $ hg log --template '{rev} {parents} {desc}\n'
308 3 b3
309 (transplanted from a53251cdf717679d1907b289f991534be05c997a)
310 2 b1
311 (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21)
312 1 r2
313 0 r1
314
315 skip previous transplants
316
317 $ hg transplant -s ../t -a -b 4
318 searching for changes
319 applying 722f4667af76
320 722f4667af76 transplanted to 47156cd86c0b
321 $ hg log --template '{rev} {parents} {desc}\n'
322 4 b2
323 3 b3
324 (transplanted from a53251cdf717679d1907b289f991534be05c997a)
325 2 b1
326 (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21)
327 1 r2
328 0 r1
329
330 skip local changes transplanted to the source
331
332 $ echo b4 > b4
333 $ hg ci -Amb4 -d '3 0'
334 adding b4
335 $ hg clone ../t ../pullback
336 updating to branch default
337 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
338 $ cd ../pullback
339 $ hg transplant -s ../remote -a -b tip
340 searching for changes
341 applying 4333daefcb15
342 4333daefcb15 transplanted to 5f42c04e07cc
343
344
345 remote transplant with pull
346
347 $ hg serve -R ../t -p $HGPORT -d --pid-file=../t.pid
348 $ cat ../t.pid >> $DAEMON_PIDS
349
350 $ hg clone -r 0 ../t ../rp
351 adding changesets
352 adding manifests
353 adding file changes
354 added 1 changesets with 1 changes to 1 files
355 new changesets 17ab29e464c6
356 updating to branch default
357 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
358 $ cd ../rp
359 $ hg transplant -s http://localhost:$HGPORT/ 37a1297eb21b a53251cdf717
360 searching for changes
361 searching for changes
362 adding changesets
363 adding manifests
364 adding file changes
365 applying a53251cdf717
366 a53251cdf717 transplanted to 8d9279348abb
367 added 1 changesets with 1 changes to 1 files
368 $ hg log --template '{rev} {parents} {desc}\n'
369 2 b3
370 1 b1
371 0 r1
372
373 remote transplant without pull
374 (It was using "2" and "4" (as the previous transplant used to) which referenced
375 revision different from one run to another)
376
377 $ hg pull -q http://localhost:$HGPORT/
378 $ hg transplant -s http://localhost:$HGPORT/ 8d9279348abb 722f4667af76
379 skipping already applied revision 2:8d9279348abb
380 applying 722f4667af76
381 722f4667af76 transplanted to 76e321915884
382
383
384 transplant --continue and --stop behaviour
385
386 $ hg init ../tc
387 $ cd ../tc
388 $ cat <<EOF > foo
389 > foo
390 > bar
391 > baz
392 > EOF
393 $ echo toremove > toremove
394 $ echo baz > baz
395 $ hg ci -Amfoo
396 adding baz
397 adding foo
398 adding toremove
399 $ cat <<EOF > foo
400 > foo2
401 > bar2
402 > baz2
403 > EOF
404 $ rm toremove
405 $ echo added > added
406 $ hg ci -Amfoo2
407 adding added
408 removing toremove
409 $ echo bar > bar
410 $ cat > baz <<EOF
411 > before baz
412 > baz
413 > after baz
414 > EOF
415 $ hg ci -Ambar
416 adding bar
417 $ echo bar2 >> bar
418 $ hg ci -mbar2
419 $ hg up 0
420 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
421 $ echo foobar > foo
422 $ hg ci -mfoobar
423 created new head
424
425 Repo log before transplant
426 $ hg glog
427 @ changeset: 4:e8643552fde5
428 | tag: tip
429 | parent: 0:493149fa1541
430 | user: test
431 | date: Thu Jan 01 00:00:00 1970 +0000
432 | summary: foobar
433 |
434 | o changeset: 3:1dab759070cf
435 | | user: test
436 | | date: Thu Jan 01 00:00:00 1970 +0000
437 | | summary: bar2
438 | |
439 | o changeset: 2:9d6d6b5a8275
440 | | user: test
441 | | date: Thu Jan 01 00:00:00 1970 +0000
442 | | summary: bar
443 | |
444 | o changeset: 1:46ae92138f3c
445 |/ user: test
446 | date: Thu Jan 01 00:00:00 1970 +0000
447 | summary: foo2
448 |
449 o changeset: 0:493149fa1541
450 user: test
451 date: Thu Jan 01 00:00:00 1970 +0000
452 summary: foo
453
454 $ hg transplant 1:3
455 applying 46ae92138f3c
456 patching file foo
457 Hunk #1 FAILED at 0
458 1 out of 1 hunks FAILED -- saving rejects to file foo.rej
459 patch failed to apply
460 abort: fix up the working directory and run hg transplant --continue
461 [255]
462
463 $ hg transplant --stop
464 stopped the interrupted transplant
465 working directory is now at e8643552fde5
466 Repo log after abort
467 $ hg glog
468 @ changeset: 4:e8643552fde5
469 | tag: tip
470 | parent: 0:493149fa1541
471 | user: test
472 | date: Thu Jan 01 00:00:00 1970 +0000
473 | summary: foobar
474 |
475 | o changeset: 3:1dab759070cf
476 | | user: test
477 | | date: Thu Jan 01 00:00:00 1970 +0000
478 | | summary: bar2
479 | |
480 | o changeset: 2:9d6d6b5a8275
481 | | user: test
482 | | date: Thu Jan 01 00:00:00 1970 +0000
483 | | summary: bar
484 | |
485 | o changeset: 1:46ae92138f3c
486 |/ user: test
487 | date: Thu Jan 01 00:00:00 1970 +0000
488 | summary: foo2
489 |
490 o changeset: 0:493149fa1541
491 user: test
492 date: Thu Jan 01 00:00:00 1970 +0000
493 summary: foo
494
495 $ hg transplant 1:3
496 applying 46ae92138f3c
497 file added already exists
498 1 out of 1 hunks FAILED -- saving rejects to file added.rej
499 patching file foo
500 Hunk #1 FAILED at 0
501 1 out of 1 hunks FAILED -- saving rejects to file foo.rej
502 patch failed to apply
503 abort: fix up the working directory and run hg transplant --continue
504 [255]
505
506 transplant -c shouldn't use an old changeset
507
508 $ hg up -C
509 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
510 updated to "e8643552fde5: foobar"
511 1 other heads for branch "default"
512 $ rm added
513 $ hg continue
514 abort: no transplant to continue (continueflag !)
515 abort: no operation in progress (no-continueflag !)
516 [20]
517 $ hg transplant --stop
518 abort: no interrupted transplant found
519 [20]
520 $ hg transplant 1
521 applying 46ae92138f3c
522 patching file foo
523 Hunk #1 FAILED at 0
524 1 out of 1 hunks FAILED -- saving rejects to file foo.rej
525 patch failed to apply
526 abort: fix up the working directory and run hg transplant --continue
527 [255]
528 $ cp .hg/transplant/journal .hg/transplant/journal.orig
529 $ cat .hg/transplant/journal
530 # User test
531 # Date 0 0
532 # Node ID 46ae92138f3ce0249f6789650403286ead052b6d
533 # Parent e8643552fde58f57515e19c4b373a57c96e62af3
534 foo2
535 $ grep -v 'Date' .hg/transplant/journal.orig > .hg/transplant/journal
536 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e
537 abort: filter corrupted changeset (no user or date)
538 [255]
539 $ cp .hg/transplant/journal.orig .hg/transplant/journal
540 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e
541 HGEDITFORM=transplant.normal
542 46ae92138f3c transplanted as 9159dada197d
543 $ hg transplant 1:3
544 skipping already applied revision 1:46ae92138f3c
545 applying 9d6d6b5a8275
546 9d6d6b5a8275 transplanted to 2d17a10c922f
547 applying 1dab759070cf
548 1dab759070cf transplanted to e06a69927eb0
549 $ hg locate
550 added
551 bar
552 baz
553 foo
554
555 test multiple revisions, --continue and hg status --verbose
556
557 $ hg up -qC 0
558 $ echo bazbaz > baz
559 $ hg ci -Am anotherbaz baz
560 created new head
561 $ hg transplant 1:3
562 applying 46ae92138f3c
563 46ae92138f3c transplanted to 1024233ea0ba
564 applying 9d6d6b5a8275
565 patching file baz
566 Hunk #1 FAILED at 0
567 1 out of 1 hunks FAILED -- saving rejects to file baz.rej
568 patch failed to apply
569 abort: fix up the working directory and run hg transplant --continue
570 [255]
571 $ hg transplant 1:3
572 abort: transplant in progress
573 (use 'hg transplant --continue' or 'hg transplant --stop')
574 [20]
575 $ hg status -v
576 A bar
577 ? added.rej
578 ? baz.rej
579 ? foo.rej
580 # The repository is in an unfinished *transplant* state.
581
582 # To continue: hg transplant --continue
583 # To stop: hg transplant --stop
584
585 $ echo fixed > baz
586 $ hg continue
587 9d6d6b5a8275 transplanted as d80c49962290
588 applying 1dab759070cf
589 1dab759070cf transplanted to aa0ffe6bd5ae
590 $ cd ..
591
592 Issue1111: Test transplant --merge
593
594 $ hg init t1111
595 $ cd t1111
596 $ echo a > a
597 $ hg ci -Am adda
598 adding a
599 $ echo b >> a
600 $ hg ci -m appendb
601 $ echo c >> a
602 $ hg ci -m appendc
603 $ hg up -C 0
604 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
605 $ echo d >> a
606 $ hg ci -m appendd
607 created new head
608
609 transplant
610
611 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant -m 1 -e
612 applying 42dc4432fd35
613 HGEDITFORM=transplant.merge
614 1:42dc4432fd35 merged at a9f4acbac129
615 $ hg update -q -C 2
616 $ cat > a <<EOF
617 > x
618 > y
619 > z
620 > EOF
621 $ hg commit -m replace
622 $ hg update -q -C 4
623 $ hg transplant -m 5
624 applying 600a3cdcb41d
625 patching file a
626 Hunk #1 FAILED at 0
627 1 out of 1 hunks FAILED -- saving rejects to file a.rej
628 patch failed to apply
629 abort: fix up the working directory and run hg transplant --continue
630 [255]
631 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e
632 HGEDITFORM=transplant.merge
633 600a3cdcb41d transplanted as a3f88be652e0
634
635 $ cd ..
636
637 test transplant into empty repository
638
639 $ hg init empty
640 $ cd empty
641 $ hg transplant -s ../t -b tip -a
642 adding changesets
643 adding manifests
644 adding file changes
645 added 4 changesets with 4 changes to 4 files
646 new changesets 17ab29e464c6:a53251cdf717
647
648 test "--merge" causing pull from source repository on local host
649
650 $ hg --config extensions.mq= -q strip 2
651 $ hg transplant -s ../t --merge tip
652 searching for changes
653 searching for changes
654 adding changesets
655 adding manifests
656 adding file changes
657 applying a53251cdf717
658 4:a53251cdf717 merged at 4831f4dc831a
659 added 2 changesets with 2 changes to 2 files
660
661 test interactive transplant
662
663 $ hg --config extensions.strip= -q strip 0
664 $ hg -R ../t log -G --template "{rev}:{node|short}"
665 @ 4:a53251cdf717
666 |
667 o 3:722f4667af76
668 |
669 o 2:37a1297eb21b
670 |
671 | o 1:d11e3596cc1a
672 |/
673 o 0:17ab29e464c6
674
675 $ hg transplant -q --config ui.interactive=true -s ../t <<EOF
676 > ?
677 > x
678 > q
679 > EOF
680 0:17ab29e464c6
681 apply changeset? [ynmpcq?]: ?
682 y: yes, transplant this changeset
683 n: no, skip this changeset
684 m: merge at this changeset
685 p: show patch
686 c: commit selected changesets
687 q: quit and cancel transplant
688 ?: ? (show this help)
689 apply changeset? [ynmpcq?]: x
690 unrecognized response
691 apply changeset? [ynmpcq?]: q
692 $ hg transplant -q --config ui.interactive=true -s ../t <<EOF
693 > p
694 > y
695 > n
696 > n
697 > m
698 > c
699 > EOF
700 0:17ab29e464c6
701 apply changeset? [ynmpcq?]: p
702 diff -r 000000000000 -r 17ab29e464c6 r1
703 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
704 +++ b/r1 Thu Jan 01 00:00:00 1970 +0000
705 @@ -0,0 +1,1 @@
706 +r1
707 apply changeset? [ynmpcq?]: y
708 1:d11e3596cc1a
709 apply changeset? [ynmpcq?]: n
710 2:37a1297eb21b
711 apply changeset? [ynmpcq?]: n
712 3:722f4667af76
713 apply changeset? [ynmpcq?]: m
714 4:a53251cdf717
715 apply changeset? [ynmpcq?]: c
716 $ hg log -G --template "{node|short}"
717 @ 88be5dde5260
718 |\
719 | o 722f4667af76
720 | |
721 | o 37a1297eb21b
722 |/
723 o 17ab29e464c6
724
725 $ hg transplant -q --config ui.interactive=true -s ../t <<EOF
726 > x
727 > ?
728 > y
729 > q
730 > EOF
731 1:d11e3596cc1a
732 apply changeset? [ynmpcq?]: x
733 unrecognized response
734 apply changeset? [ynmpcq?]: ?
735 y: yes, transplant this changeset
736 n: no, skip this changeset
737 m: merge at this changeset
738 p: show patch
739 c: commit selected changesets
740 q: quit and cancel transplant
741 ?: ? (show this help)
742 apply changeset? [ynmpcq?]: y
743 4:a53251cdf717
744 apply changeset? [ynmpcq?]: q
745 $ hg heads --template "{node|short}\n"
746 88be5dde5260
747
748 $ cd ..
749
750
751 #if unix-permissions system-sh
752
753 test filter
754
755 $ hg init filter
756 $ cd filter
757 $ cat <<'EOF' >test-filter
758 > #!/bin/sh
759 > sed 's/r1/r2/' $1 > $1.new
760 > mv $1.new $1
761 > EOF
762 $ chmod +x test-filter
763 $ hg transplant -s ../t -b tip -a --filter ./test-filter
764 filtering * (glob)
765 applying 17ab29e464c6
766 17ab29e464c6 transplanted to e9ffc54ea104
767 filtering * (glob)
768 applying 37a1297eb21b
769 37a1297eb21b transplanted to 348b36d0b6a5
770 filtering * (glob)
771 applying 722f4667af76
772 722f4667af76 transplanted to 0aa6979afb95
773 filtering * (glob)
774 applying a53251cdf717
775 a53251cdf717 transplanted to 14f8512272b5
776 $ hg log --template '{rev} {parents} {desc}\n'
777 3 b3
778 2 b2
779 1 b1
780 0 r2
781 $ cd ..
782
783
784 test filter with failed patch
785
786 $ cd filter
787 $ hg up 0
788 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
789 $ echo foo > b1
790 $ hg ci -Am foo
791 adding b1
792 adding test-filter
793 created new head
794 $ hg transplant 1 --filter ./test-filter
795 filtering * (glob)
796 applying 348b36d0b6a5
797 file b1 already exists
798 1 out of 1 hunks FAILED -- saving rejects to file b1.rej
799 patch failed to apply
800 abort: fix up the working directory and run hg transplant --continue
801 [255]
802 $ cd ..
803
804 test environment passed to filter
805
806 $ hg init filter-environment
807 $ cd filter-environment
808 $ cat <<'EOF' >test-filter-environment
809 > #!/bin/sh
810 > echo "Transplant by $HGUSER" >> $1
811 > echo "Transplant from rev $HGREVISION" >> $1
812 > EOF
813 $ chmod +x test-filter-environment
814 $ hg transplant -s ../t --filter ./test-filter-environment 0
815 filtering * (glob)
816 applying 17ab29e464c6
817 17ab29e464c6 transplanted to 5190e68026a0
818
819 $ hg log --template '{rev} {parents} {desc}\n'
820 0 r1
821 Transplant by test
822 Transplant from rev 17ab29e464c6ca53e329470efe2a9918ac617a6f
823 $ cd ..
824
825 test transplant with filter handles invalid changelog
826
827 $ hg init filter-invalid-log
828 $ cd filter-invalid-log
829 $ cat <<'EOF' >test-filter-invalid-log
830 > #!/bin/sh
831 > echo "" > $1
832 > EOF
833 $ chmod +x test-filter-invalid-log
834 $ hg transplant -s ../t --filter ./test-filter-invalid-log 0
835 filtering * (glob)
836 abort: filter corrupted changeset (no user or date)
837 [255]
838 $ cd ..
839
840 #endif
841
842
843 test with a win32ext like setup (differing EOLs)
844
845 $ hg init twin1
846 $ cd twin1
847 $ echo a > a
848 $ echo b > b
849 $ echo b >> b
850 $ hg ci -Am t
851 adding a
852 adding b
853 $ echo a > b
854 $ echo b >> b
855 $ hg ci -m changeb
856 $ cd ..
857
858 $ hg init twin2
859 $ cd twin2
860 $ echo '[patch]' >> .hg/hgrc
861 $ echo 'eol = crlf' >> .hg/hgrc
862 $ "$PYTHON" -c "open('b', 'wb').write(b'b\r\nb\r\n')"
863 $ hg ci -Am addb
864 adding b
865 $ hg transplant -s ../twin1 tip
866 searching for changes
867 warning: repository is unrelated
868 applying 2e849d776c17
869 2e849d776c17 transplanted to 8e65bebc063e
870 $ cat b
871 a\r (esc)
872 b\r (esc)
873 $ cd ..
874
875 test transplant with merge changeset is skipped
876
877 $ hg init merge1a
878 $ cd merge1a
879 $ echo a > a
880 $ hg ci -Am a
881 adding a
882 $ hg branch b
883 marked working directory as branch b
884 (branches are permanent and global, did you want a bookmark?)
885 $ hg ci -m branchb
886 $ echo b > b
887 $ hg ci -Am b
888 adding b
889 $ hg update default
890 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
891 $ hg merge b
892 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
893 (branch merge, don't forget to commit)
894 $ hg ci -m mergeb
895 $ cd ..
896
897 $ hg init merge1b
898 $ cd merge1b
899 $ hg transplant -s ../merge1a tip
900 $ cd ..
901
902 test transplant with merge changeset accepts --parent
903
904 $ hg init merge2a
905 $ cd merge2a
906 $ echo a > a
907 $ hg ci -Am a
908 adding a
909 $ hg branch b
910 marked working directory as branch b
911 (branches are permanent and global, did you want a bookmark?)
912 $ hg ci -m branchb
913 $ echo b > b
914 $ hg ci -Am b
915 adding b
916 $ hg update default
917 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
918 $ hg merge b
919 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
920 (branch merge, don't forget to commit)
921 $ hg ci -m mergeb
922 $ cd ..
923
924 $ hg init merge2b
925 $ cd merge2b
926 $ hg transplant -s ../merge2a --parent tip tip
927 abort: be9f9b39483f is not a parent of be9f9b39483f
928 [255]
929 $ hg transplant -s ../merge2a --parent 0 tip
930 applying be9f9b39483f
931 be9f9b39483f transplanted to 9959e51f94d1
932 $ cd ..
933
934 test transplanting a patch turning into a no-op
935
936 $ hg init binarysource
937 $ cd binarysource
938 $ echo a > a
939 $ hg ci -Am adda a
940 >>> open('b', 'wb').write(b'\0b1') and None
941 $ hg ci -Am addb b
942 >>> open('b', 'wb').write(b'\0b2') and None
943 $ hg ci -m changeb b
944 $ cd ..
945
946 $ hg clone -r0 binarysource binarydest
947 adding changesets
948 adding manifests
949 adding file changes
950 added 1 changesets with 1 changes to 1 files
951 new changesets 07f494440405
952 updating to branch default
953 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
954 $ cd binarydest
955 $ cp ../binarysource/b b
956 $ hg ci -Am addb2 b
957 $ hg transplant -s ../binarysource 2
958 searching for changes
959 applying 7a7d57e15850
960 skipping emptied changeset 7a7d57e15850
961
962 Test empty result in --continue
963
964 $ hg transplant -s ../binarysource 1
965 searching for changes
966 applying 645035761929
967 file b already exists
968 1 out of 1 hunks FAILED -- saving rejects to file b.rej
969 patch failed to apply
970 abort: fix up the working directory and run hg transplant --continue
971 [255]
972 $ hg status
973 ? b.rej
974 $ hg continue
975 645035761929 skipped due to empty diff
976
977 $ cd ..
978
979 Explicitly kill daemons to let the test exit on Windows
980
981 $ killdaemons.py
982
983 Test that patch-ed files are treated as "modified", when transplant is
984 aborted by failure of patching, even if none of mode, size and
985 timestamp of them isn't changed on the filesystem (see also issue4583)
986
987 $ cd t
988
989 $ cat > $TESTTMP/abort.py <<EOF
990 > # emulate that patch.patch() is aborted at patching on "abort" file
991 > from mercurial import error, extensions, patch as patchmod
992 > def patch(orig, ui, repo, patchname,
993 > strip=1, prefix=b'', files=None,
994 > eolmode=b'strict', similarity=0):
995 > if files is None:
996 > files = set()
997 > r = orig(ui, repo, patchname,
998 > strip=strip, prefix=prefix, files=files,
999 > eolmode=eolmode, similarity=similarity)
1000 > if b'abort' in files:
1001 > raise error.PatchError('intentional error while patching')
1002 > return r
1003 > def extsetup(ui):
1004 > extensions.wrapfunction(patchmod, 'patch', patch)
1005 > EOF
1006
1007 $ echo X1 > r1
1008 $ hg diff --nodates r1
1009 diff -r a53251cdf717 r1
1010 --- a/r1
1011 +++ b/r1
1012 @@ -1,1 +1,1 @@
1013 -r1
1014 +X1
1015 $ hg commit -m "X1 as r1"
1016
1017 $ echo 'marking to abort patching' > abort
1018 $ hg add abort
1019 $ echo Y1 > r1
1020 $ hg diff --nodates r1
1021 diff -r 22c515968f13 r1
1022 --- a/r1
1023 +++ b/r1
1024 @@ -1,1 +1,1 @@
1025 -X1
1026 +Y1
1027 $ hg commit -m "Y1 as r1"
1028
1029 $ hg update -q -C d11e3596cc1a
1030 $ cat r1
1031 r1
1032
1033 $ cat >> .hg/hgrc <<EOF
1034 > [fakedirstatewritetime]
1035 > # emulate invoking dirstate.write() via repo.status() or markcommitted()
1036 > # at 2000-01-01 00:00
1037 > fakenow = 200001010000
1038 >
1039 > # emulate invoking patch.internalpatch() at 2000-01-01 00:00
1040 > [fakepatchtime]
1041 > fakenow = 200001010000
1042 >
1043 > [extensions]
1044 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1045 > fakepatchtime = $TESTDIR/fakepatchtime.py
1046 > abort = $TESTTMP/abort.py
1047 > EOF
1048 $ hg transplant "22c515968f13::"
1049 applying 22c515968f13
1050 22c515968f13 transplanted to * (glob)
1051 applying e38700ba9dd3
1052 intentional error while patching
1053 abort: fix up the working directory and run hg transplant --continue
1054 [255]
1055 $ cat >> .hg/hgrc <<EOF
1056 > [hooks]
1057 > fakedirstatewritetime = !
1058 > fakepatchtime = !
1059 > [extensions]
1060 > abort = !
1061 > EOF
1062
1063 $ cat r1
1064 Y1
1065 $ hg debugstate | grep ' r1$'
1066 n 0 -1 unset r1
1067 $ hg status -A r1
1068 M r1
1069
1070 Test that rollback by unexpected failure after transplanting the first
1071 revision restores dirstate correctly.
1072
1073 $ hg rollback -q
1074 $ rm -f abort
1075 $ hg update -q -C d11e3596cc1a
1076 $ hg parents -T "{node|short}\n"
1077 d11e3596cc1a
1078 $ hg status -A
1079 C r1
1080 C r2
1081
1082 $ cat >> .hg/hgrc <<EOF
1083 > [hooks]
1084 > # emulate failure at transplanting the 2nd revision
1085 > pretxncommit.abort = test ! -f abort
1086 > EOF
1087 $ hg transplant "22c515968f13::"
1088 applying 22c515968f13
1089 22c515968f13 transplanted to * (glob)
1090 applying e38700ba9dd3
1091 transaction abort!
1092 rollback completed
1093 abort: pretxncommit.abort hook exited with status 1
1094 [40]
1095 $ cat >> .hg/hgrc <<EOF
1096 > [hooks]
1097 > pretxncommit.abort = !
1098 > EOF
1099
1100 $ hg parents -T "{node|short}\n"
1101 d11e3596cc1a
1102 $ hg status -A
1103 M r1
1104 ? abort
1105 C r2
1106
1107 $ cd ..