Debian Codegraph @

tests/test-split.t

raw
1 #testcases obsstore-on obsstore-off
2
3 $ cat > $TESTTMP/editor.py <<EOF
4 > #!"$PYTHON"
5 > import os
6 > import sys
7 > path = os.path.join(os.environ['TESTTMP'], 'messages')
8 > messages = open(path).read().split('--\n')
9 > prompt = open(sys.argv[1]).read()
10 > sys.stdout.write(''.join('EDITOR: %s' % l for l in prompt.splitlines(True)))
11 > sys.stdout.flush()
12 > with open(sys.argv[1], 'w') as f:
13 > f.write(messages[0])
14 > with open(path, 'w') as f:
15 > f.write('--\n'.join(messages[1:]))
16 > EOF
17
18 $ cat >> $HGRCPATH <<EOF
19 > [extensions]
20 > drawdag=$TESTDIR/drawdag.py
21 > split=
22 > [ui]
23 > interactive=1
24 > color=no
25 > paginate=never
26 > [diff]
27 > git=1
28 > unified=0
29 > [commands]
30 > commit.interactive.unified=0
31 > [alias]
32 > glog=log -G -T '{rev}:{node|short} {desc} {bookmarks}\n'
33 > EOF
34
35 #if obsstore-on
36 $ cat >> $HGRCPATH <<EOF
37 > [experimental]
38 > evolution=all
39 > EOF
40 #endif
41
42 $ hg init a
43 $ cd a
44
45 Nothing to split
46
47 $ hg split
48 nothing to split
49 [1]
50
51 $ hg commit -m empty --config ui.allowemptycommit=1
52 $ hg split
53 abort: cannot split an empty revision
54 [10]
55
56 $ rm -rf .hg
57 $ hg init
58
59 Cannot split working directory
60
61 $ hg split -r 'wdir()'
62 abort: cannot split working directory
63 [10]
64
65 Generate some content. The sed filter drop CR on Windows, which is dropped in
66 the a > b line.
67
68 $ $TESTDIR/seq.py 1 5 >> a
69 $ hg ci -m a1 -A a -q
70 $ hg bookmark -i r1
71 $ sed 's/1/11/;s/3/33/;s/5/55/' a > b
72 $ mv b a
73 $ hg ci -m a2 -q
74 $ hg bookmark -i r2
75
76 Cannot split a public changeset
77
78 $ hg phase --public -r 'all()'
79 $ hg split .
80 abort: cannot split public changesets: 1df0d5c5a3ab
81 (see 'hg help phases' for details)
82 [10]
83
84 $ hg phase --draft -f -r 'all()'
85
86 Cannot split while working directory is dirty
87
88 $ touch dirty
89 $ hg add dirty
90 $ hg split .
91 abort: uncommitted changes
92 [20]
93 $ hg forget dirty
94 $ rm dirty
95
96 Make a clean directory for future tests to build off of
97
98 $ cp -R . ../clean
99
100 Split a head
101
102 $ hg bookmark r3
103
104 $ hg split 'all()'
105 abort: cannot split multiple revisions
106 [10]
107
108 This function splits a bit strangely primarily to avoid changing the behavior of
109 the test after a bug was fixed with how split/commit --interactive handled
110 `commands.commit.interactive.unified=0`: when there were no context lines,
111 it kept only the last diff hunk. When running split, this meant that runsplit
112 was always recording three commits, one for each diff hunk, in reverse order
113 (the base commit was the last diff hunk in the file).
114 $ runsplit() {
115 > cat > $TESTTMP/messages <<EOF
116 > split 1
117 > --
118 > split 2
119 > --
120 > split 3
121 > EOF
122 > cat <<EOF | hg split "$@"
123 > y
124 > n
125 > n
126 > y
127 > y
128 > n
129 > y
130 > y
131 > y
132 > EOF
133 > }
134
135 $ HGEDITOR=false runsplit
136 diff --git a/a b/a
137 3 hunks, 3 lines changed
138 examine changes to 'a'?
139 (enter ? for help) [Ynesfdaq?] y
140
141 @@ -1,1 +1,1 @@
142 -1
143 +11
144 record change 1/3 to 'a'?
145 (enter ? for help) [Ynesfdaq?] n
146
147 @@ -3,1 +3,1 @@
148 -3
149 +33
150 record change 2/3 to 'a'?
151 (enter ? for help) [Ynesfdaq?] n
152
153 @@ -5,1 +5,1 @@
154 -5
155 +55
156 record change 3/3 to 'a'?
157 (enter ? for help) [Ynesfdaq?] y
158
159 abort: edit failed: false exited with status 1
160 [250]
161 $ hg status
162
163 $ HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py"
164 $ runsplit
165 diff --git a/a b/a
166 3 hunks, 3 lines changed
167 examine changes to 'a'?
168 (enter ? for help) [Ynesfdaq?] y
169
170 @@ -1,1 +1,1 @@
171 -1
172 +11
173 record change 1/3 to 'a'?
174 (enter ? for help) [Ynesfdaq?] n
175
176 @@ -3,1 +3,1 @@
177 -3
178 +33
179 record change 2/3 to 'a'?
180 (enter ? for help) [Ynesfdaq?] n
181
182 @@ -5,1 +5,1 @@
183 -5
184 +55
185 record change 3/3 to 'a'?
186 (enter ? for help) [Ynesfdaq?] y
187
188 EDITOR: HG: Splitting 1df0d5c5a3ab. Write commit message for the first split changeset.
189 EDITOR: a2
190 EDITOR:
191 EDITOR:
192 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
193 EDITOR: HG: Leave message empty to abort commit.
194 EDITOR: HG: --
195 EDITOR: HG: user: test
196 EDITOR: HG: branch 'default'
197 EDITOR: HG: changed a
198 created new head
199 diff --git a/a b/a
200 2 hunks, 2 lines changed
201 examine changes to 'a'?
202 (enter ? for help) [Ynesfdaq?] y
203
204 @@ -1,1 +1,1 @@
205 -1
206 +11
207 record change 1/2 to 'a'?
208 (enter ? for help) [Ynesfdaq?] n
209
210 @@ -3,1 +3,1 @@
211 -3
212 +33
213 record change 2/2 to 'a'?
214 (enter ? for help) [Ynesfdaq?] y
215
216 EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into:
217 EDITOR: HG: - 2:e704349bd21b tip "split 1"
218 EDITOR: HG: Write commit message for the next split changeset.
219 EDITOR: a2
220 EDITOR:
221 EDITOR:
222 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
223 EDITOR: HG: Leave message empty to abort commit.
224 EDITOR: HG: --
225 EDITOR: HG: user: test
226 EDITOR: HG: branch 'default'
227 EDITOR: HG: changed a
228 diff --git a/a b/a
229 1 hunks, 1 lines changed
230 examine changes to 'a'?
231 (enter ? for help) [Ynesfdaq?] y
232
233 @@ -1,1 +1,1 @@
234 -1
235 +11
236 record this change to 'a'?
237 (enter ? for help) [Ynesfdaq?] y
238
239 EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into:
240 EDITOR: HG: - 2:e704349bd21b tip "split 1"
241 EDITOR: HG: - 3:a09ad58faae3 "split 2"
242 EDITOR: HG: Write commit message for the next split changeset.
243 EDITOR: a2
244 EDITOR:
245 EDITOR:
246 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
247 EDITOR: HG: Leave message empty to abort commit.
248 EDITOR: HG: --
249 EDITOR: HG: user: test
250 EDITOR: HG: branch 'default'
251 EDITOR: HG: changed a
252 saved backup bundle to $TESTTMP/a/.hg/strip-backup/1df0d5c5a3ab-8341b760-split.hg (obsstore-off !)
253
254 #if obsstore-off
255 $ hg bookmark
256 r1 0:a61bcde8c529
257 r2 3:00eebaf8d2e2
258 * r3 3:00eebaf8d2e2
259 $ hg glog -p
260 @ 3:00eebaf8d2e2 split 3 r2 r3
261 | diff --git a/a b/a
262 | --- a/a
263 | +++ b/a
264 | @@ -1,1 +1,1 @@
265 | -1
266 | +11
267 |
268 o 2:a09ad58faae3 split 2
269 | diff --git a/a b/a
270 | --- a/a
271 | +++ b/a
272 | @@ -3,1 +3,1 @@
273 | -3
274 | +33
275 |
276 o 1:e704349bd21b split 1
277 | diff --git a/a b/a
278 | --- a/a
279 | +++ b/a
280 | @@ -5,1 +5,1 @@
281 | -5
282 | +55
283 |
284 o 0:a61bcde8c529 a1 r1
285 diff --git a/a b/a
286 new file mode 100644
287 --- /dev/null
288 +++ b/a
289 @@ -0,0 +1,5 @@
290 +1
291 +2
292 +3
293 +4
294 +5
295
296 #else
297 $ hg bookmark
298 r1 0:a61bcde8c529
299 r2 4:00eebaf8d2e2
300 * r3 4:00eebaf8d2e2
301 $ hg glog
302 @ 4:00eebaf8d2e2 split 3 r2 r3
303 |
304 o 3:a09ad58faae3 split 2
305 |
306 o 2:e704349bd21b split 1
307 |
308 o 0:a61bcde8c529 a1 r1
309
310 #endif
311
312 Split a head while working parent is not that head
313
314 $ cp -R $TESTTMP/clean $TESTTMP/b
315 $ cd $TESTTMP/b
316
317 $ hg up 0 -q
318 $ hg bookmark r3
319
320 $ runsplit tip >/dev/null
321
322 #if obsstore-off
323 $ hg bookmark
324 r1 0:a61bcde8c529
325 r2 3:00eebaf8d2e2
326 * r3 0:a61bcde8c529
327 $ hg glog
328 o 3:00eebaf8d2e2 split 3 r2
329 |
330 o 2:a09ad58faae3 split 2
331 |
332 o 1:e704349bd21b split 1
333 |
334 @ 0:a61bcde8c529 a1 r1 r3
335
336 #else
337 $ hg bookmark
338 r1 0:a61bcde8c529
339 r2 4:00eebaf8d2e2
340 * r3 0:a61bcde8c529
341 $ hg glog
342 o 4:00eebaf8d2e2 split 3 r2
343 |
344 o 3:a09ad58faae3 split 2
345 |
346 o 2:e704349bd21b split 1
347 |
348 @ 0:a61bcde8c529 a1 r1 r3
349
350 #endif
351
352 Split a non-head
353
354 $ cp -R $TESTTMP/clean $TESTTMP/c
355 $ cd $TESTTMP/c
356 $ echo d > d
357 $ hg ci -m d1 -A d
358 $ hg bookmark -i d1
359 $ echo 2 >> d
360 $ hg ci -m d2
361 $ echo 3 >> d
362 $ hg ci -m d3
363 $ hg bookmark -i d3
364 $ hg up '.^' -q
365 $ hg bookmark d2
366 $ cp -R . ../d
367
368 $ runsplit -r 1 | grep rebasing
369 rebasing 2:b5c5ea414030 d1 "d1"
370 rebasing 3:f4a0a8d004cc d2 "d2"
371 rebasing 4:777940761eba d3 "d3"
372 #if obsstore-off
373 $ hg bookmark
374 d1 4:c4b449ef030e
375 * d2 5:c9dd00ab36a3
376 d3 6:19f476bc865c
377 r1 0:a61bcde8c529
378 r2 3:00eebaf8d2e2
379 $ hg glog -p
380 o 6:19f476bc865c d3 d3
381 | diff --git a/d b/d
382 | --- a/d
383 | +++ b/d
384 | @@ -2,0 +3,1 @@
385 | +3
386 |
387 @ 5:c9dd00ab36a3 d2 d2
388 | diff --git a/d b/d
389 | --- a/d
390 | +++ b/d
391 | @@ -1,0 +2,1 @@
392 | +2
393 |
394 o 4:c4b449ef030e d1 d1
395 | diff --git a/d b/d
396 | new file mode 100644
397 | --- /dev/null
398 | +++ b/d
399 | @@ -0,0 +1,1 @@
400 | +d
401 |
402 o 3:00eebaf8d2e2 split 3 r2
403 | diff --git a/a b/a
404 | --- a/a
405 | +++ b/a
406 | @@ -1,1 +1,1 @@
407 | -1
408 | +11
409 |
410 o 2:a09ad58faae3 split 2
411 | diff --git a/a b/a
412 | --- a/a
413 | +++ b/a
414 | @@ -3,1 +3,1 @@
415 | -3
416 | +33
417 |
418 o 1:e704349bd21b split 1
419 | diff --git a/a b/a
420 | --- a/a
421 | +++ b/a
422 | @@ -5,1 +5,1 @@
423 | -5
424 | +55
425 |
426 o 0:a61bcde8c529 a1 r1
427 diff --git a/a b/a
428 new file mode 100644
429 --- /dev/null
430 +++ b/a
431 @@ -0,0 +1,5 @@
432 +1
433 +2
434 +3
435 +4
436 +5
437
438 #else
439 $ hg bookmark
440 d1 8:c4b449ef030e
441 * d2 9:c9dd00ab36a3
442 d3 10:19f476bc865c
443 r1 0:a61bcde8c529
444 r2 7:00eebaf8d2e2
445 $ hg glog
446 o 10:19f476bc865c d3 d3
447 |
448 @ 9:c9dd00ab36a3 d2 d2
449 |
450 o 8:c4b449ef030e d1 d1
451 |
452 o 7:00eebaf8d2e2 split 3 r2
453 |
454 o 6:a09ad58faae3 split 2
455 |
456 o 5:e704349bd21b split 1
457 |
458 o 0:a61bcde8c529 a1 r1
459
460 #endif
461
462 Split a non-head without rebase
463
464 $ cd $TESTTMP/d
465 #if obsstore-off
466 $ runsplit -r 1 --no-rebase
467 abort: cannot split changeset, as that will orphan 3 descendants
468 (see 'hg help evolution.instability')
469 [10]
470 #else
471 $ runsplit -r 1 --no-rebase >/dev/null
472 3 new orphan changesets
473 $ hg bookmark
474 d1 2:b5c5ea414030
475 * d2 3:f4a0a8d004cc
476 d3 4:777940761eba
477 r1 0:a61bcde8c529
478 r2 7:00eebaf8d2e2
479
480 $ hg glog
481 o 7:00eebaf8d2e2 split 3 r2
482 |
483 o 6:a09ad58faae3 split 2
484 |
485 o 5:e704349bd21b split 1
486 |
487 | * 4:777940761eba d3 d3
488 | |
489 | @ 3:f4a0a8d004cc d2 d2
490 | |
491 | * 2:b5c5ea414030 d1 d1
492 | |
493 | x 1:1df0d5c5a3ab a2
494 |/
495 o 0:a61bcde8c529 a1 r1
496
497 #endif
498
499 Split a non-head with obsoleted descendants
500
501 #if obsstore-on
502 $ hg init $TESTTMP/e
503 $ cd $TESTTMP/e
504 $ hg debugdrawdag <<'EOS'
505 > H I J
506 > | | |
507 > F G1 G2 # amend: G1 -> G2
508 > | | / # prune: F
509 > C D E
510 > \|/
511 > B
512 > |
513 > A
514 > EOS
515 2 new orphan changesets
516 $ eval `hg tags -T '{tag}={node}\n'`
517 $ rm .hg/localtags
518 $ hg split $B --config experimental.evolution=createmarkers
519 abort: cannot split changeset, as that will orphan 4 descendants
520 (see 'hg help evolution.instability')
521 [10]
522 $ cat > $TESTTMP/messages <<EOF
523 > Split B
524 > EOF
525 $ cat <<EOF | hg split $B
526 > y
527 > y
528 > EOF
529 diff --git a/B b/B
530 new file mode 100644
531 examine changes to 'B'?
532 (enter ? for help) [Ynesfdaq?] y
533
534 @@ -0,0 +1,1 @@
535 +B
536 \ No newline at end of file
537 record this change to 'B'?
538 (enter ? for help) [Ynesfdaq?] y
539
540 EDITOR: HG: Splitting 112478962961. Write commit message for the first split changeset.
541 EDITOR: B
542 EDITOR:
543 EDITOR:
544 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
545 EDITOR: HG: Leave message empty to abort commit.
546 EDITOR: HG: --
547 EDITOR: HG: user: test
548 EDITOR: HG: branch 'default'
549 EDITOR: HG: added B
550 created new head
551 rebasing 2:26805aba1e60 "C"
552 rebasing 3:be0ef73c17ad "D"
553 rebasing 4:49cb92066bfd "E"
554 rebasing 7:97a6268cc7ef "G2"
555 rebasing 10:e2f1e425c0db "J"
556 $ hg glog -r 'sort(all(), topo)'
557 o 16:556c085f8b52 J
558 |
559 o 15:8761f6c9123f G2
560 |
561 o 14:a7aeffe59b65 E
562 |
563 | o 13:e1e914ede9ab D
564 |/
565 | o 12:01947e9b98aa C
566 |/
567 o 11:0947baa74d47 Split B
568 |
569 | * 9:88ede1d5ee13 I
570 | |
571 | x 6:af8cbf225b7b G1
572 | |
573 | x 3:be0ef73c17ad D
574 | |
575 | | * 8:74863e5b5074 H
576 | | |
577 | | x 5:ee481a2a1e69 F
578 | | |
579 | | x 2:26805aba1e60 C
580 | |/
581 | x 1:112478962961 B
582 |/
583 o 0:426bada5c675 A
584
585 #endif
586
587 Preserve secret phase in split
588
589 $ cp -R $TESTTMP/clean $TESTTMP/phases1
590 $ cd $TESTTMP/phases1
591 $ hg phase --secret -fr tip
592 $ hg log -T '{short(node)} {phase}\n'
593 1df0d5c5a3ab secret
594 a61bcde8c529 draft
595 $ runsplit tip >/dev/null
596 $ hg log -T '{short(node)} {phase}\n'
597 00eebaf8d2e2 secret
598 a09ad58faae3 secret
599 e704349bd21b secret
600 a61bcde8c529 draft
601
602 Do not move things to secret even if phases.new-commit=secret
603
604 $ cp -R $TESTTMP/clean $TESTTMP/phases2
605 $ cd $TESTTMP/phases2
606 $ cat >> .hg/hgrc <<EOF
607 > [phases]
608 > new-commit=secret
609 > EOF
610 $ hg log -T '{short(node)} {phase}\n'
611 1df0d5c5a3ab draft
612 a61bcde8c529 draft
613 $ runsplit tip >/dev/null
614 $ hg log -T '{short(node)} {phase}\n'
615 00eebaf8d2e2 draft
616 a09ad58faae3 draft
617 e704349bd21b draft
618 a61bcde8c529 draft
619
620 `hg split` with ignoreblanklines=1 does not infinite loop
621
622 $ mkdir $TESTTMP/f
623 $ hg init $TESTTMP/f/a
624 $ cd $TESTTMP/f/a
625 $ printf '1\n2\n3\n4\n5\n' > foo
626 $ cp foo bar
627 $ hg ci -qAm initial
628 $ printf '1\n\n2\n3\ntest\n4\n5\n' > bar
629 $ printf '1\n2\n3\ntest\n4\n5\n' > foo
630 $ hg ci -qm splitme
631 $ cat > $TESTTMP/messages <<EOF
632 > split 1
633 > --
634 > split 2
635 > EOF
636 $ printf 'f\nn\nf\n' | hg --config extensions.split= --config diff.ignoreblanklines=1 split
637 diff --git a/bar b/bar
638 2 hunks, 2 lines changed
639 examine changes to 'bar'?
640 (enter ? for help) [Ynesfdaq?] f
641
642 diff --git a/foo b/foo
643 1 hunks, 1 lines changed
644 examine changes to 'foo'?
645 (enter ? for help) [Ynesfdaq?] n
646
647 EDITOR: HG: Splitting dd3c45017cbf. Write commit message for the first split changeset.
648 EDITOR: splitme
649 EDITOR:
650 EDITOR:
651 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
652 EDITOR: HG: Leave message empty to abort commit.
653 EDITOR: HG: --
654 EDITOR: HG: user: test
655 EDITOR: HG: branch 'default'
656 EDITOR: HG: changed bar
657 created new head
658 diff --git a/foo b/foo
659 1 hunks, 1 lines changed
660 examine changes to 'foo'?
661 (enter ? for help) [Ynesfdaq?] f
662
663 EDITOR: HG: Splitting dd3c45017cbf. So far it has been split into:
664 EDITOR: HG: - 2:f205aea1c624 tip "split 1"
665 EDITOR: HG: Write commit message for the next split changeset.
666 EDITOR: splitme
667 EDITOR:
668 EDITOR:
669 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
670 EDITOR: HG: Leave message empty to abort commit.
671 EDITOR: HG: --
672 EDITOR: HG: user: test
673 EDITOR: HG: branch 'default'
674 EDITOR: HG: changed foo
675 saved backup bundle to $TESTTMP/f/a/.hg/strip-backup/dd3c45017cbf-463441b5-split.hg (obsstore-off !)
676
677 Let's try that again, with a slightly different set of patches, to ensure that
678 the ignoreblanklines thing isn't somehow position dependent.
679
680 $ hg init $TESTTMP/f/b
681 $ cd $TESTTMP/f/b
682 $ printf '1\n2\n3\n4\n5\n' > foo
683 $ cp foo bar
684 $ hg ci -qAm initial
685 $ printf '1\n2\n3\ntest\n4\n5\n' > bar
686 $ printf '1\n2\n3\ntest\n4\n\n5\n' > foo
687 $ hg ci -qm splitme
688 $ cat > $TESTTMP/messages <<EOF
689 > split 1
690 > --
691 > split 2
692 > EOF
693 $ printf 'f\nn\nf\n' | hg --config extensions.split= --config diff.ignoreblanklines=1 split
694 diff --git a/bar b/bar
695 1 hunks, 1 lines changed
696 examine changes to 'bar'?
697 (enter ? for help) [Ynesfdaq?] f
698
699 diff --git a/foo b/foo
700 2 hunks, 2 lines changed
701 examine changes to 'foo'?
702 (enter ? for help) [Ynesfdaq?] n
703
704 EDITOR: HG: Splitting 904c80b40a4a. Write commit message for the first split changeset.
705 EDITOR: splitme
706 EDITOR:
707 EDITOR:
708 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
709 EDITOR: HG: Leave message empty to abort commit.
710 EDITOR: HG: --
711 EDITOR: HG: user: test
712 EDITOR: HG: branch 'default'
713 EDITOR: HG: changed bar
714 created new head
715 diff --git a/foo b/foo
716 2 hunks, 2 lines changed
717 examine changes to 'foo'?
718 (enter ? for help) [Ynesfdaq?] f
719
720 EDITOR: HG: Splitting 904c80b40a4a. So far it has been split into:
721 EDITOR: HG: - 2:ffecf40fa954 tip "split 1"
722 EDITOR: HG: Write commit message for the next split changeset.
723 EDITOR: splitme
724 EDITOR:
725 EDITOR:
726 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
727 EDITOR: HG: Leave message empty to abort commit.
728 EDITOR: HG: --
729 EDITOR: HG: user: test
730 EDITOR: HG: branch 'default'
731 EDITOR: HG: changed foo
732 saved backup bundle to $TESTTMP/f/b/.hg/strip-backup/904c80b40a4a-47fb907f-split.hg (obsstore-off !)
733
734
735 Testing the case in split when commiting flag-only file changes (issue5864)
736 ---------------------------------------------------------------------------
737 $ hg init $TESTTMP/issue5864
738 $ cd $TESTTMP/issue5864
739 $ echo foo > foo
740 $ hg add foo
741 $ hg ci -m "initial"
742 $ hg import -q --bypass -m "make executable" - <<EOF
743 > diff --git a/foo b/foo
744 > old mode 100644
745 > new mode 100755
746 > EOF
747 $ hg up -q
748
749 $ hg glog
750 @ 1:3a2125f0f4cb make executable
751 |
752 o 0:51f273a58d82 initial
753
754
755 #if no-windows
756 $ cat > $TESTTMP/messages <<EOF
757 > split 1
758 > EOF
759 $ printf 'y\n' | hg split
760 diff --git a/foo b/foo
761 old mode 100644
762 new mode 100755
763 examine changes to 'foo'?
764 (enter ? for help) [Ynesfdaq?] y
765
766 EDITOR: HG: Splitting 3a2125f0f4cb. Write commit message for the first split changeset.
767 EDITOR: make executable
768 EDITOR:
769 EDITOR:
770 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
771 EDITOR: HG: Leave message empty to abort commit.
772 EDITOR: HG: --
773 EDITOR: HG: user: test
774 EDITOR: HG: branch 'default'
775 EDITOR: HG: changed foo
776 created new head
777 saved backup bundle to $TESTTMP/issue5864/.hg/strip-backup/3a2125f0f4cb-629e4432-split.hg (obsstore-off !)
778
779 $ hg log -G -T "{node|short} {desc}\n"
780 @ b154670c87da split 1
781 |
782 o 51f273a58d82 initial
783
784 #else
785
786 TODO: Fix this on Windows. See issue 2020 and 5883
787
788 $ printf 'y\ny\ny\n' | hg split
789 abort: cannot split an empty revision
790 [10]
791 #endif
792
793 Test that splitting moves works properly (issue5723)
794 ----------------------------------------------------
795
796 $ hg init $TESTTMP/issue5723-mv
797 $ cd $TESTTMP/issue5723-mv
798 $ printf '1\n2\n' > file
799 $ hg ci -qAm initial
800 $ hg mv file file2
801 $ printf 'a\nb\n1\n2\n3\n4\n' > file2
802 $ cat > $TESTTMP/messages <<EOF
803 > split1, keeping only the numbered lines
804 > --
805 > split2, keeping the lettered lines
806 > EOF
807 $ hg ci -m 'move and modify'
808 $ printf 'y\nn\na\na\n' | hg split
809 diff --git a/file b/file2
810 rename from file
811 rename to file2
812 2 hunks, 4 lines changed
813 examine changes to 'file' and 'file2'?
814 (enter ? for help) [Ynesfdaq?] y
815
816 @@ -0,0 +1,2 @@
817 +a
818 +b
819 record change 1/2 to 'file2'?
820 (enter ? for help) [Ynesfdaq?] n
821
822 @@ -2,0 +5,2 @@
823 +3
824 +4
825 record change 2/2 to 'file2'?
826 (enter ? for help) [Ynesfdaq?] a
827
828 EDITOR: HG: Splitting 8c42fa635116. Write commit message for the first split changeset.
829 EDITOR: move and modify
830 EDITOR:
831 EDITOR:
832 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
833 EDITOR: HG: Leave message empty to abort commit.
834 EDITOR: HG: --
835 EDITOR: HG: user: test
836 EDITOR: HG: branch 'default'
837 EDITOR: HG: added file2
838 EDITOR: HG: removed file
839 created new head
840 diff --git a/file2 b/file2
841 1 hunks, 2 lines changed
842 examine changes to 'file2'?
843 (enter ? for help) [Ynesfdaq?] a
844
845 EDITOR: HG: Splitting 8c42fa635116. So far it has been split into:
846 EDITOR: HG: - 2:478be2a70c27 tip "split1, keeping only the numbered lines"
847 EDITOR: HG: Write commit message for the next split changeset.
848 EDITOR: move and modify
849 EDITOR:
850 EDITOR:
851 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
852 EDITOR: HG: Leave message empty to abort commit.
853 EDITOR: HG: --
854 EDITOR: HG: user: test
855 EDITOR: HG: branch 'default'
856 EDITOR: HG: changed file2
857 saved backup bundle to $TESTTMP/issue5723-mv/.hg/strip-backup/8c42fa635116-a38044d4-split.hg (obsstore-off !)
858 $ hg log -T '{desc}: {files%"{file} "}\n'
859 split2, keeping the lettered lines: file2
860 split1, keeping only the numbered lines: file file2
861 initial: file
862 $ cat file2
863 a
864 b
865 1
866 2
867 3
868 4
869 $ hg cat -r ".^" file2
870 1
871 2
872 3
873 4
874 $ hg cat -r . file2
875 a
876 b
877 1
878 2
879 3
880 4
881
882
883 Test that splitting copies works properly (issue5723)
884 ----------------------------------------------------
885
886 $ hg init $TESTTMP/issue5723-cp
887 $ cd $TESTTMP/issue5723-cp
888 $ printf '1\n2\n' > file
889 $ hg ci -qAm initial
890 $ hg cp file file2
891 $ printf 'a\nb\n1\n2\n3\n4\n' > file2
892 Also modify 'file' to prove that the changes aren't being pulled in
893 accidentally.
894 $ printf 'this is the new contents of "file"' > file
895 $ cat > $TESTTMP/messages <<EOF
896 > split1, keeping "file" and only the numbered lines in file2
897 > --
898 > split2, keeping the lettered lines in file2
899 > EOF
900 $ hg ci -m 'copy file->file2, modify both'
901 $ printf 'f\ny\nn\na\na\n' | hg split
902 diff --git a/file b/file
903 1 hunks, 2 lines changed
904 examine changes to 'file'?
905 (enter ? for help) [Ynesfdaq?] f
906
907 diff --git a/file b/file2
908 copy from file
909 copy to file2
910 2 hunks, 4 lines changed
911 examine changes to 'file' and 'file2'?
912 (enter ? for help) [Ynesfdaq?] y
913
914 @@ -0,0 +1,2 @@
915 +a
916 +b
917 record change 2/3 to 'file2'?
918 (enter ? for help) [Ynesfdaq?] n
919
920 @@ -2,0 +5,2 @@
921 +3
922 +4
923 record change 3/3 to 'file2'?
924 (enter ? for help) [Ynesfdaq?] a
925
926 EDITOR: HG: Splitting 41c861dfa61e. Write commit message for the first split changeset.
927 EDITOR: copy file->file2, modify both
928 EDITOR:
929 EDITOR:
930 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
931 EDITOR: HG: Leave message empty to abort commit.
932 EDITOR: HG: --
933 EDITOR: HG: user: test
934 EDITOR: HG: branch 'default'
935 EDITOR: HG: added file2
936 EDITOR: HG: changed file
937 created new head
938 diff --git a/file2 b/file2
939 1 hunks, 2 lines changed
940 examine changes to 'file2'?
941 (enter ? for help) [Ynesfdaq?] a
942
943 EDITOR: HG: Splitting 41c861dfa61e. So far it has been split into:
944 EDITOR: HG: - 2:4b19e06610eb tip "split1, keeping "file" and only the numbered lines in file2"
945 EDITOR: HG: Write commit message for the next split changeset.
946 EDITOR: copy file->file2, modify both
947 EDITOR:
948 EDITOR:
949 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
950 EDITOR: HG: Leave message empty to abort commit.
951 EDITOR: HG: --
952 EDITOR: HG: user: test
953 EDITOR: HG: branch 'default'
954 EDITOR: HG: changed file2
955 saved backup bundle to $TESTTMP/issue5723-cp/.hg/strip-backup/41c861dfa61e-467e8d3c-split.hg (obsstore-off !)
956 $ hg log -T '{desc}: {files%"{file} "}\n'
957 split2, keeping the lettered lines in file2: file2
958 split1, keeping "file" and only the numbered lines in file2: file file2
959 initial: file
960 $ cat file2
961 a
962 b
963 1
964 2
965 3
966 4
967 $ hg cat -r ".^" file2
968 1
969 2
970 3
971 4
972 $ hg cat -r . file2
973 a
974 b
975 1
976 2
977 3
978 4
979
980 Test that color codes don't end up in the commit message template
981 ----------------------------------------------------
982
983 $ hg init $TESTTMP/colorless
984 $ cd $TESTTMP/colorless
985 $ echo 1 > file1
986 $ echo 1 > file2
987 $ hg ci -qAm initial
988 $ echo 2 > file1
989 $ echo 2 > file2
990 $ cat > $TESTTMP/messages <<EOF
991 > split1, modifying file1
992 > --
993 > split2, modifying file2
994 > EOF
995 $ hg ci
996 EDITOR:
997 EDITOR:
998 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
999 EDITOR: HG: Leave message empty to abort commit.
1000 EDITOR: HG: --
1001 EDITOR: HG: user: test
1002 EDITOR: HG: branch 'default'
1003 EDITOR: HG: changed file1
1004 EDITOR: HG: changed file2
1005 $ printf 'f\nn\na\n' | hg split --color=debug \
1006 > --config command-templates.oneline-summary='{label("rev", rev)} {desc}'
1007 [diff.diffline|diff --git a/file1 b/file1]
1008 1 hunks, 1 lines changed
1009 [ ui.prompt|examine changes to 'file1'?
1010 (enter ? for help) [Ynesfdaq?]] [ ui.promptecho|f]
1011
1012 [diff.diffline|diff --git a/file2 b/file2]
1013 1 hunks, 1 lines changed
1014 [ ui.prompt|examine changes to 'file2'?
1015 (enter ? for help) [Ynesfdaq?]] [ ui.promptecho|n]
1016
1017 EDITOR: HG: Splitting 6432c65c3078. Write commit message for the first split changeset.
1018 EDITOR: split1, modifying file1
1019 EDITOR:
1020 EDITOR:
1021 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
1022 EDITOR: HG: Leave message empty to abort commit.
1023 EDITOR: HG: --
1024 EDITOR: HG: user: test
1025 EDITOR: HG: branch 'default'
1026 EDITOR: HG: changed file1
1027 [ ui.status|created new head]
1028 [diff.diffline|diff --git a/file2 b/file2]
1029 1 hunks, 1 lines changed
1030 [ ui.prompt|examine changes to 'file2'?
1031 (enter ? for help) [Ynesfdaq?]] [ ui.promptecho|a]
1032
1033 EDITOR: HG: Splitting 6432c65c3078. So far it has been split into:
1034 EDITOR: HG: - 2 split2, modifying file2
1035 EDITOR: HG: Write commit message for the next split changeset.
1036 EDITOR: split1, modifying file1
1037 EDITOR:
1038 EDITOR:
1039 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
1040 EDITOR: HG: Leave message empty to abort commit.
1041 EDITOR: HG: --
1042 EDITOR: HG: user: test
1043 EDITOR: HG: branch 'default'
1044 EDITOR: HG: changed file2
1045 [ ui.warning|transaction abort!]
1046 [ ui.warning|rollback completed]
1047 [ ui.error|abort: empty commit message]
1048 [10]
1049
1050 Test that creating an empty split or "no-op"
1051 (identical to original) commit doesn't cause chaos
1052 --------------------------------------------------
1053
1054 $ hg init $TESTTMP/noop
1055 $ cd $TESTTMP/noop
1056 $ echo r0 > r0
1057 $ hg ci -qAm r0
1058 $ hg phase -p
1059 $ echo foo > foo
1060 $ hg ci -qAm foo
1061 $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
1062 @ draft 1:ae694b2901bb foo
1063 |
1064 o public 0:222799e2f90b r0
1065
1066 $ printf 'd\na\n' | HGEDITOR=cat hg split || true
1067 diff --git a/foo b/foo
1068 new file mode 100644
1069 examine changes to 'foo'?
1070 (enter ? for help) [Ynesfdaq?] d
1071
1072 no changes to record
1073 diff --git a/foo b/foo
1074 new file mode 100644
1075 examine changes to 'foo'?
1076 (enter ? for help) [Ynesfdaq?] a
1077
1078 HG: Splitting ae694b2901bb. Write commit message for the first split changeset.
1079 foo
1080
1081
1082 HG: Enter commit message. Lines beginning with 'HG:' are removed.
1083 HG: Leave message empty to abort commit.
1084 HG: --
1085 HG: user: test
1086 HG: branch 'default'
1087 HG: added foo
1088 warning: commit already existed in the repository!
1089 $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
1090 @ draft 1:ae694b2901bb foo
1091 |
1092 o public 0:222799e2f90b r0
1093
1094
1095 Now try the same thing but modifying the message so we don't trigger the
1096 identical changeset failures
1097
1098 $ hg init $TESTTMP/noop2
1099 $ cd $TESTTMP/noop2
1100 $ echo r0 > r0
1101 $ hg ci -qAm r0
1102 $ hg phase -p
1103 $ echo foo > foo
1104 $ hg ci -qAm foo
1105 $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
1106 @ draft 1:ae694b2901bb foo
1107 |
1108 o public 0:222799e2f90b r0
1109
1110 $ cat > $TESTTMP/messages <<EOF
1111 > message1
1112 > EOF
1113 $ printf 'd\na\n' | HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py" hg split
1114 diff --git a/foo b/foo
1115 new file mode 100644
1116 examine changes to 'foo'?
1117 (enter ? for help) [Ynesfdaq?] d
1118
1119 no changes to record
1120 diff --git a/foo b/foo
1121 new file mode 100644
1122 examine changes to 'foo'?
1123 (enter ? for help) [Ynesfdaq?] a
1124
1125 EDITOR: HG: Splitting ae694b2901bb. Write commit message for the first split changeset.
1126 EDITOR: foo
1127 EDITOR:
1128 EDITOR:
1129 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed.
1130 EDITOR: HG: Leave message empty to abort commit.
1131 EDITOR: HG: --
1132 EDITOR: HG: user: test
1133 EDITOR: HG: branch 'default'
1134 EDITOR: HG: added foo
1135 created new head
1136 saved backup bundle to $TESTTMP/noop2/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
1137 $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
1138 @ draft 1:de675559d3f9 message1 (obsstore-off !)
1139 @ draft 2:de675559d3f9 message1 (obsstore-on !)
1140 |
1141 o public 0:222799e2f90b r0
1142
1143 #if obsstore-on
1144 $ hg debugobsolete
1145 ae694b2901bb8b0f8c4b5e075ddec0d63468d57a de675559d3f93ffc822c6eb7490e5c73033f17c7 0 * (glob)
1146 #endif