Debian Codegraph @

tests/test-histedit-arguments.t

raw
1 #testcases abortcommand abortflag
2
3 #if abortflag
4 $ cat >> $HGRCPATH <<EOF
5 > [alias]
6 > abort = histedit --abort
7 > EOF
8 #endif
9
10 Test argument handling and various data parsing
11 ==================================================
12
13
14 Enable extensions used by this test.
15 $ cat >>$HGRCPATH <<EOF
16 > [extensions]
17 > histedit=
18 > EOF
19
20 Repo setup.
21 $ hg init foo
22 $ cd foo
23 $ echo alpha >> alpha
24 $ hg addr
25 adding alpha
26 $ hg ci -m one
27 $ echo alpha >> alpha
28 $ hg ci -m two
29 $ echo alpha >> alpha
30 $ hg ci -m three
31 $ echo alpha >> alpha
32 $ hg ci -m four
33 $ echo alpha >> alpha
34 $ hg ci -m five
35
36 $ hg log --style compact --graph
37 @ 4[tip] 08d98a8350f3 1970-01-01 00:00 +0000 test
38 | five
39 |
40 o 3 c8e68270e35a 1970-01-01 00:00 +0000 test
41 | four
42 |
43 o 2 eb57da33312f 1970-01-01 00:00 +0000 test
44 | three
45 |
46 o 1 579e40513370 1970-01-01 00:00 +0000 test
47 | two
48 |
49 o 0 6058cbb6cfd7 1970-01-01 00:00 +0000 test
50 one
51
52
53 histedit --continue/--abort with no existing state
54 --------------------------------------------------
55
56 $ hg histedit --continue
57 abort: no histedit in progress
58 [20]
59 $ hg abort
60 abort: no histedit in progress (abortflag !)
61 abort: no operation in progress (abortcommand !)
62 [20]
63
64 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
65 --------------------------------------------------------------------
66
67 $ HGEDITOR=cat hg histedit "tip^^"
68 pick eb57da33312f 2 three
69 pick c8e68270e35a 3 four
70 pick 08d98a8350f3 4 five
71
72 # Edit history between eb57da33312f and 08d98a8350f3
73 #
74 # Commits are listed from least to most recent
75 #
76 # You can reorder changesets by reordering the lines
77 #
78 # Commands:
79 #
80 # e, edit = use commit, but allow edits before making new commit
81 # m, mess = edit commit message without changing commit content
82 # p, pick = use commit
83 # b, base = checkout changeset and apply further changesets from there
84 # d, drop = remove commit from history
85 # f, fold = use commit, but combine it with the one above
86 # r, roll = like fold, but discard this commit's description and date
87 #
88
89 Run on a revision not ancestors of the current working directory.
90 --------------------------------------------------------------------
91
92 $ hg up 2
93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
94 $ hg histedit -r 4
95 abort: 08d98a8350f3 is not an ancestor of working directory
96 [10]
97 $ hg up --quiet
98
99
100 Test that we pick the minimum of a revrange
101 ---------------------------------------
102
103 $ HGEDITOR=cat hg histedit '2::' --commands - << EOF
104 > pick eb57da33312f 2 three
105 > pick c8e68270e35a 3 four
106 > pick 08d98a8350f3 4 five
107 > EOF
108 $ hg up --quiet
109
110 $ HGEDITOR=cat hg histedit 'tip:2' --commands - << EOF
111 > pick eb57da33312f 2 three
112 > pick c8e68270e35a 3 four
113 > pick 08d98a8350f3 4 five
114 > EOF
115 $ hg up --quiet
116
117 Test config specified default
118 -----------------------------
119
120 $ HGEDITOR=cat hg histedit --config "histedit.defaultrev=only(.) - ::eb57da33312f" --commands - << EOF
121 > pick c8e68270e35a 3 four
122 > pick 08d98a8350f3 4 five
123 > EOF
124
125 Test invalid config default
126 ---------------------------
127
128 $ hg histedit --config "histedit.defaultrev="
129 config error: config option histedit.defaultrev can't be empty
130 [30]
131
132 Run on a revision not descendants of the initial parent
133 --------------------------------------------------------------------
134
135 Test the message shown for inconsistent histedit state, which may be
136 created (and forgotten) by Mercurial earlier than 2.7. This emulates
137 Mercurial earlier than 2.7 by renaming ".hg/histedit-state"
138 temporarily.
139
140 $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
141 @ 4 08d9 five
142 |
143 o 3 c8e6 four
144 |
145 o 2 eb57 three
146 |
147 ~
148 $ HGEDITOR=cat hg histedit -r 4 --commands - << EOF
149 > edit 08d98a8350f3 4 five
150 > EOF
151 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
152 Editing (08d98a8350f3), commit as needed now to split the change
153 (to edit 08d98a8350f3, `hg histedit --continue` after making changes)
154 [240]
155
156 $ hg graft --continue
157 abort: no graft in progress
158 (continue: hg histedit --continue)
159 [20]
160
161 $ mv .hg/histedit-state .hg/histedit-state.back
162 $ hg update --quiet --clean 2
163 $ echo alpha >> alpha
164 $ mv .hg/histedit-state.back .hg/histedit-state
165
166 $ hg continue
167 saved backup bundle to $TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
168 $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
169 @ 4 f5ed five
170 |
171 | o 3 c8e6 four
172 |/
173 o 2 eb57 three
174 |
175 ~
176
177 $ hg unbundle -q $TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
178 $ hg strip -q -r f5ed --config extensions.strip=
179 $ hg up -q 08d98a8350f3
180
181 Test that missing revisions are detected
182 ---------------------------------------
183
184 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
185 > pick eb57da33312f 2 three
186 > pick 08d98a8350f3 4 five
187 > EOF
188 hg: parse error: missing rules for changeset c8e68270e35a
189 (use "drop c8e68270e35a" to discard, see also: 'hg help -e histedit.config')
190 [10]
191
192 Test that extra revisions are detected
193 ---------------------------------------
194
195 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
196 > pick 6058cbb6cfd7 0 one
197 > pick c8e68270e35a 3 four
198 > pick 08d98a8350f3 4 five
199 > EOF
200 hg: parse error: pick "6058cbb6cfd7" changeset was not a candidate
201 (only use listed changesets)
202 [10]
203
204 Test malformed line
205 ---------------------------------------
206
207 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
208 > pickeb57da33312f2three
209 > pick c8e68270e35a 3 four
210 > pick 08d98a8350f3 4 five
211 > EOF
212 hg: parse error: malformed line "pickeb57da33312f2three"
213 [10]
214
215 Test unknown changeset
216 ---------------------------------------
217
218 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
219 > pick 0123456789ab 2 three
220 > pick c8e68270e35a 3 four
221 > pick 08d98a8350f3 4 five
222 > EOF
223 hg: parse error: unknown changeset 0123456789ab listed
224 [10]
225
226 Test unknown command
227 ---------------------------------------
228
229 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
230 > coin eb57da33312f 2 three
231 > pick c8e68270e35a 3 four
232 > pick 08d98a8350f3 4 five
233 > EOF
234 hg: parse error: unknown action "coin"
235 [10]
236
237 Test duplicated changeset
238 ---------------------------------------
239
240 So one is missing and one appear twice.
241
242 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
243 > pick eb57da33312f 2 three
244 > pick eb57da33312f 2 three
245 > pick 08d98a8350f3 4 five
246 > EOF
247 hg: parse error: duplicated command for changeset eb57da33312f
248 [10]
249
250 Test bogus rev
251 ---------------------------------------
252
253 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
254 > pick eb57da33312f 2 three
255 > pick 0u98
256 > pick 08d98a8350f3 4 five
257 > EOF
258 hg: parse error: invalid changeset 0u98
259 [10]
260
261 Test short version of command
262 ---------------------------------------
263
264 Note: we use varying amounts of white space between command name and changeset
265 short hash. This tests issue3893.
266
267 $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
268 > pick eb57da33312f 2 three
269 > p c8e68270e35a 3 four
270 > f 08d98a8350f3 4 five
271 > EOF
272 four
273 ***
274 five
275
276
277
278 HG: Enter commit message. Lines beginning with 'HG:' are removed.
279 HG: Leave message empty to abort commit.
280 HG: --
281 HG: user: test
282 HG: branch 'default'
283 HG: changed alpha
284 saved backup bundle to $TESTTMP/foo/.hg/strip-backup/c8e68270e35a-63d8b8d8-histedit.hg
285
286 $ hg update -q 2
287 $ echo x > x
288 $ hg add x
289 $ hg commit -m'x' x
290 created new head
291 $ hg histedit -r 'heads(all())'
292 abort: The specified revisions must have exactly one common root
293 [10]
294
295 Test that trimming description using multi-byte characters
296 --------------------------------------------------------------------
297
298 $ "$PYTHON" <<EOF
299 > fp = open('logfile', 'wb')
300 > fp.write(b'12345678901234567890123456789012345678901234567890' +
301 > b'12345') # there are 5 more columns for 80 columns
302 >
303 > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes
304 > fp.write(u'\u3042\u3044\u3046\u3048'.encode('utf-8'))
305 >
306 > fp.close()
307 > EOF
308 $ echo xx >> x
309 $ hg --encoding utf-8 commit --logfile logfile
310
311 $ HGEDITOR=cat hg --encoding utf-8 histedit tip
312 pick 3d3ea1f3a10b 5 1234567890123456789012345678901234567890123456789012345\xe3\x81\x82... (esc)
313
314 # Edit history between 3d3ea1f3a10b and 3d3ea1f3a10b
315 #
316 # Commits are listed from least to most recent
317 #
318 # You can reorder changesets by reordering the lines
319 #
320 # Commands:
321 #
322 # e, edit = use commit, but allow edits before making new commit
323 # m, mess = edit commit message without changing commit content
324 # p, pick = use commit
325 # b, base = checkout changeset and apply further changesets from there
326 # d, drop = remove commit from history
327 # f, fold = use commit, but combine it with the one above
328 # r, roll = like fold, but discard this commit's description and date
329 #
330
331 Test --continue with --keep
332
333 $ hg strip -q -r . --config extensions.strip=
334 $ hg histedit '.^' -q --keep --commands - << EOF
335 > edit eb57da33312f 2 three
336 > pick f3cfcca30c44 4 x
337 > EOF
338 Editing (eb57da33312f), commit as needed now to split the change
339 (to edit eb57da33312f, `hg histedit --continue` after making changes)
340 [240]
341 $ echo edit >> alpha
342 $ hg histedit -q --continue
343 $ hg log -G -T '{rev}:{node|short} {desc}'
344 @ 6:8fda0c726bf2 x
345 |
346 o 5:63379946892c three
347 |
348 | o 4:f3cfcca30c44 x
349 | |
350 | | o 3:2a30f3cfee78 four
351 | |/ ***
352 | | five
353 | o 2:eb57da33312f three
354 |/
355 o 1:579e40513370 two
356 |
357 o 0:6058cbb6cfd7 one
358
359
360 Test that abort fails gracefully on exception
361 ----------------------------------------------
362 $ hg histedit . -q --commands - << EOF
363 > edit 8fda0c726bf2 6 x
364 > EOF
365 Editing (8fda0c726bf2), commit as needed now to split the change
366 (to edit 8fda0c726bf2, `hg histedit --continue` after making changes)
367 [240]
368 Corrupt histedit state file
369 $ sed 's/8fda0c726bf2/123456789012/' .hg/histedit-state > ../corrupt-histedit
370 $ mv ../corrupt-histedit .hg/histedit-state
371 $ hg abort
372 warning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up
373 abort: $TESTTMP/foo/.hg/strip-backup/*-histedit.hg: $ENOENT$ (glob) (windows !)
374 abort: $ENOENT$: '$TESTTMP/foo/.hg/strip-backup/*-histedit.hg' (glob) (no-windows !)
375 [255]
376 Histedit state has been exited
377 $ hg summary -q
378 parent: 5:63379946892c
379 commit: 1 added, 1 unknown (new branch head)
380 update: 4 new changesets (update)
381
382 $ cd ..
383
384 Set up default base revision tests
385
386 $ hg init defaultbase
387 $ cd defaultbase
388 $ touch foo
389 $ hg -q commit -A -m root
390 $ echo 1 > foo
391 $ hg commit -m 'public 1'
392 $ hg phase --force --public -r .
393 $ echo 2 > foo
394 $ hg commit -m 'draft after public'
395 $ hg -q up -r 1
396 $ echo 3 > foo
397 $ hg commit -m 'head 1 public'
398 created new head
399 $ hg phase --force --public -r .
400 $ echo 4 > foo
401 $ hg commit -m 'head 1 draft 1'
402 $ echo 5 > foo
403 $ hg commit -m 'head 1 draft 2'
404 $ hg -q up -r 2
405 $ echo 6 > foo
406 $ hg commit -m 'head 2 commit 1'
407 $ echo 7 > foo
408 $ hg commit -m 'head 2 commit 2'
409 $ hg -q up -r 2
410 $ echo 8 > foo
411 $ hg commit -m 'head 3'
412 created new head
413 $ hg -q up -r 2
414 $ echo 9 > foo
415 $ hg commit -m 'head 4'
416 created new head
417 $ hg merge --tool :local -r 8
418 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
419 (branch merge, don't forget to commit)
420 $ hg commit -m 'merge head 3 into head 4'
421 $ echo 11 > foo
422 $ hg commit -m 'commit 1 after merge'
423 $ echo 12 > foo
424 $ hg commit -m 'commit 2 after merge'
425
426 $ hg log -G -T '{rev}:{node|short} {phase} {desc}\n'
427 @ 12:8cde254db839 draft commit 2 after merge
428 |
429 o 11:6f2f0241f119 draft commit 1 after merge
430 |
431 o 10:90506cc76b00 draft merge head 3 into head 4
432 |\
433 | o 9:f8607a373a97 draft head 4
434 | |
435 o | 8:0da92be05148 draft head 3
436 |/
437 | o 7:4c35cdf97d5e draft head 2 commit 2
438 | |
439 | o 6:931820154288 draft head 2 commit 1
440 |/
441 | o 5:8cdc02b9bc63 draft head 1 draft 2
442 | |
443 | o 4:463b8c0d2973 draft head 1 draft 1
444 | |
445 | o 3:23a0c4eefcbf public head 1 public
446 | |
447 o | 2:4117331c3abb draft draft after public
448 |/
449 o 1:4426d359ea59 public public 1
450 |
451 o 0:54136a8ddf32 public root
452
453
454 Default base revision should stop at public changesets
455
456 $ hg -q up 8cdc02b9bc63
457 $ hg histedit --commands - <<EOF
458 > pick 463b8c0d2973
459 > pick 8cdc02b9bc63
460 > EOF
461
462 Default base revision should stop at branchpoint
463
464 $ hg -q up 4c35cdf97d5e
465 $ hg histedit --commands - <<EOF
466 > pick 931820154288
467 > pick 4c35cdf97d5e
468 > EOF
469
470 Default base revision should stop at merge commit
471
472 $ hg -q up 8cde254db839
473 $ hg histedit --commands - <<EOF
474 > pick 6f2f0241f119
475 > pick 8cde254db839
476 > EOF
477
478 commit --amend should abort if histedit is in progress
479 (issue4800) and markers are not being created.
480 Eventually, histedit could perhaps look at `source` extra,
481 in which case this test should be revisited.
482
483 $ hg -q up 8cde254db839
484 $ hg histedit 6f2f0241f119 --commands - <<EOF
485 > pick 8cde254db839
486 > edit 6f2f0241f119
487 > EOF
488 merging foo
489 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
490 Fix up the change (pick 8cde254db839)
491 (hg histedit --continue to resume)
492 [240]
493 $ hg resolve -m --all
494 (no more unresolved files)
495 continue: hg histedit --continue
496 $ hg histedit --cont
497 merging foo
498 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
499 Editing (6f2f0241f119), commit as needed now to split the change
500 (to edit 6f2f0241f119, `hg histedit --continue` after making changes)
501 [240]
502 $ hg resolve -m --all
503 (no more unresolved files)
504 continue: hg histedit --continue
505 $ hg commit --amend -m 'reject this fold'
506 abort: histedit in progress
507 (use 'hg histedit --continue' or 'hg histedit --abort')
508 [20]
509
510 With markers enabled, histedit does not get confused, and
511 amend should not be blocked by the ongoing histedit.
512
513 $ cat >>$HGRCPATH <<EOF
514 > [experimental]
515 > evolution.createmarkers=True
516 > evolution.allowunstable=True
517 > EOF
518 $ hg commit --amend -m 'allow this fold'
519 $ hg histedit --continue
520
521 $ cd ..
522
523 Test autoverb feature
524
525 $ hg init autoverb
526 $ cd autoverb
527 $ echo alpha >> alpha
528 $ hg ci -qAm one
529 $ echo alpha >> alpha
530 $ hg ci -qm two
531 $ echo beta >> beta
532 $ hg ci -qAm "roll! one"
533
534 $ hg log --style compact --graph
535 @ 2[tip] 4f34d0f8b5fa 1970-01-01 00:00 +0000 test
536 | roll! one
537 |
538 o 1 579e40513370 1970-01-01 00:00 +0000 test
539 | two
540 |
541 o 0 6058cbb6cfd7 1970-01-01 00:00 +0000 test
542 one
543
544
545 Check that 'roll' is selected by default
546
547 $ HGEDITOR=cat hg histedit 0 --config experimental.histedit.autoverb=True
548 pick 6058cbb6cfd7 0 one
549 roll 4f34d0f8b5fa 2 roll! one
550 pick 579e40513370 1 two
551
552 # Edit history between 6058cbb6cfd7 and 4f34d0f8b5fa
553 #
554 # Commits are listed from least to most recent
555 #
556 # You can reorder changesets by reordering the lines
557 #
558 # Commands:
559 #
560 # e, edit = use commit, but allow edits before making new commit
561 # m, mess = edit commit message without changing commit content
562 # p, pick = use commit
563 # b, base = checkout changeset and apply further changesets from there
564 # d, drop = remove commit from history
565 # f, fold = use commit, but combine it with the one above
566 # r, roll = like fold, but discard this commit's description and date
567 #
568
569 $ cd ..
570
571 Check that histedit's commands accept revsets
572 $ hg init bar
573 $ cd bar
574 $ echo w >> a
575 $ hg ci -qAm "adds a"
576 $ echo x >> b
577 $ hg ci -qAm "adds b"
578 $ echo y >> c
579 $ hg ci -qAm "adds c"
580 $ echo z >> d
581 $ hg ci -qAm "adds d"
582 $ hg log -G -T '{rev} {desc}\n'
583 @ 3 adds d
584 |
585 o 2 adds c
586 |
587 o 1 adds b
588 |
589 o 0 adds a
590
591 $ HGEDITOR=cat hg histedit "2" --commands - << EOF
592 > base -4 adds c
593 > pick 2 adds c
594 > pick tip adds d
595 > EOF
596 $ hg log -G -T '{rev} {desc}\n'
597 @ 5 adds d
598 |
599 o 4 adds c
600 |
601 | o 1 adds b
602 |/
603 o 0 adds a
604
605