Debian Codegraph @

tests/test-histedit-obsolete.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 $ . "$TESTDIR/histedit-helpers.sh"
11
12 Enable obsolete
13
14 $ cat >> $HGRCPATH << EOF
15 > [ui]
16 > logtemplate= {rev}:{node|short} {desc|firstline}
17 > [phases]
18 > publish=False
19 > [experimental]
20 > evolution.createmarkers=True
21 > evolution.allowunstable=True
22 > [extensions]
23 > histedit=
24 > rebase=
25 > EOF
26
27 Test that histedit learns about obsolescence not stored in histedit state
28 $ hg init boo
29 $ cd boo
30 $ echo a > a
31 $ hg ci -Am a
32 adding a
33 $ echo a > b
34 $ echo a > c
35 $ echo a > c
36 $ hg ci -Am b
37 adding b
38 adding c
39 $ echo a > d
40 $ hg ci -Am c
41 adding d
42 $ echo "pick `hg log -r 0 -T '{node|short}'`" > plan
43 $ echo "pick `hg log -r 2 -T '{node|short}'`" >> plan
44 $ echo "edit `hg log -r 1 -T '{node|short}'`" >> plan
45 $ hg histedit -r 'all()' --commands plan
46 Editing (1b2d564fad96), commit as needed now to split the change
47 (to edit 1b2d564fad96, `hg histedit --continue` after making changes)
48 [240]
49 $ hg st
50 A b
51 A c
52 ? plan
53 $ hg commit --amend b
54 $ hg histedit --continue
55 $ hg log -G
56 @ 5:46abc7c4d873 b
57 |
58 o 4:49d44ab2be1b c
59 |
60 o 0:cb9a9f314b8b a
61
62 $ hg debugobsolete
63 e72d22b19f8ecf4150ab4f91d0973fd9955d3ddf 49d44ab2be1b67a79127568a67c9c99430633b48 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
64 1b2d564fad96311b45362f17c2aa855150efb35f 46abc7c4d8738e8563e577f7889e1b6db3da4199 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'histedit', 'user': 'test'}
65 114f4176969ef342759a8a57e6bccefc4234829b 49d44ab2be1b67a79127568a67c9c99430633b48 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'histedit', 'user': 'test'}
66
67 With some node gone missing during the edit.
68
69 $ echo "pick `hg log -r 0 -T '{node|short}'`" > plan
70 $ echo "pick `hg log -r 5 -T '{node|short}'`" >> plan
71 $ echo "edit `hg log -r 4 -T '{node|short}'`" >> plan
72 $ hg histedit -r 'all()' --commands plan
73 Editing (49d44ab2be1b), commit as needed now to split the change
74 (to edit 49d44ab2be1b, `hg histedit --continue` after making changes)
75 [240]
76 $ hg st
77 A b
78 A d
79 ? plan
80 $ hg commit --amend -X . -m XXXXXX
81 $ hg commit --amend -X . -m b2
82 $ hg --hidden --config extensions.strip= strip 'desc(XXXXXX)' --no-backup
83 $ hg continue
84 $ hg log -G
85 @ 8:273c1f3b8626 c
86 |
87 o 7:aba7da937030 b2
88 |
89 o 0:cb9a9f314b8b a
90
91 $ hg debugobsolete
92 e72d22b19f8ecf4150ab4f91d0973fd9955d3ddf 49d44ab2be1b67a79127568a67c9c99430633b48 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
93 1b2d564fad96311b45362f17c2aa855150efb35f 46abc7c4d8738e8563e577f7889e1b6db3da4199 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'histedit', 'user': 'test'}
94 114f4176969ef342759a8a57e6bccefc4234829b 49d44ab2be1b67a79127568a67c9c99430633b48 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'histedit', 'user': 'test'}
95 76f72745eac0643d16530e56e2f86e36e40631f1 2ca853e48edbd6453a0674dc0fe28a0974c51b9c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
96 2ca853e48edbd6453a0674dc0fe28a0974c51b9c aba7da93703075eec9fb1dbaf143ff2bc1c49d46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
97 49d44ab2be1b67a79127568a67c9c99430633b48 273c1f3b86267ed3ec684bb13af1fa4d6ba56e02 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'histedit', 'user': 'test'}
98 46abc7c4d8738e8563e577f7889e1b6db3da4199 aba7da93703075eec9fb1dbaf143ff2bc1c49d46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '5', 'operation': 'histedit', 'user': 'test'}
99 $ cd ..
100
101 Base setup for the rest of the testing
102 ======================================
103
104 $ hg init base
105 $ cd base
106
107 $ for x in a b c d e f ; do
108 > echo $x > $x
109 > hg add $x
110 > hg ci -m $x
111 > done
112
113 $ hg log --graph
114 @ 5:652413bf663e f
115 |
116 o 4:e860deea161a e
117 |
118 o 3:055a42cdd887 d
119 |
120 o 2:177f92b77385 c
121 |
122 o 1:d2ae7f538514 b
123 |
124 o 0:cb9a9f314b8b a
125
126
127 $ HGEDITOR=cat hg histedit 1
128 pick d2ae7f538514 1 b
129 pick 177f92b77385 2 c
130 pick 055a42cdd887 3 d
131 pick e860deea161a 4 e
132 pick 652413bf663e 5 f
133
134 # Edit history between d2ae7f538514 and 652413bf663e
135 #
136 # Commits are listed from least to most recent
137 #
138 # You can reorder changesets by reordering the lines
139 #
140 # Commands:
141 #
142 # e, edit = use commit, but allow edits before making new commit
143 # m, mess = edit commit message without changing commit content
144 # p, pick = use commit
145 # b, base = checkout changeset and apply further changesets from there
146 # d, drop = remove commit from history
147 # f, fold = use commit, but combine it with the one above
148 # r, roll = like fold, but discard this commit's description and date
149 #
150 $ hg histedit 1 --commands - --verbose <<EOF | grep histedit
151 > pick 177f92b77385 2 c
152 > drop d2ae7f538514 1 b
153 > pick 055a42cdd887 3 d
154 > fold e860deea161a 4 e
155 > pick 652413bf663e 5 f
156 > EOF
157 [1]
158 $ hg log --graph --hidden
159 @ 10:cacdfd884a93 f
160 |
161 o 9:59d9f330561f d
162 |
163 | x 8:b558abc46d09 fold-temp-revision e860deea161a
164 | |
165 | x 7:96e494a2d553 d
166 |/
167 o 6:b346ab9a313d c
168 |
169 | x 5:652413bf663e f
170 | |
171 | x 4:e860deea161a e
172 | |
173 | x 3:055a42cdd887 d
174 | |
175 | x 2:177f92b77385 c
176 | |
177 | x 1:d2ae7f538514 b
178 |/
179 o 0:cb9a9f314b8b a
180
181 $ hg debugobsolete
182 d2ae7f538514cd87c17547b0de4cea71fe1af9fb 0 {cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'histedit', 'user': 'test'}
183 177f92b773850b59254aa5e923436f921b55483b b346ab9a313db8537ecf96fca3ca3ca984ef3bd7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'histedit', 'user': 'test'}
184 055a42cdd88768532f9cf79daa407fc8d138de9b 59d9f330561fd6c88b1a6b32f0e45034d88db784 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'histedit', 'user': 'test'}
185 e860deea161a2f77de56603b340ebbb4536308ae 59d9f330561fd6c88b1a6b32f0e45034d88db784 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'histedit', 'user': 'test'}
186 652413bf663ef2a641cab26574e46d5f5a64a55a cacdfd884a9321ec4e1de275ef3949fa953a1f83 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'histedit', 'user': 'test'}
187 96e494a2d553dd05902ba1cee1d94d4cb7b8faed 0 {b346ab9a313db8537ecf96fca3ca3ca984ef3bd7} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'histedit', 'user': 'test'}
188 b558abc46d09c30f57ac31e85a8a3d64d2e906e4 0 {96e494a2d553dd05902ba1cee1d94d4cb7b8faed} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'histedit', 'user': 'test'}
189
190
191 Ensure hidden revision does not prevent histedit
192 -------------------------------------------------
193
194 create an hidden revision
195
196 $ hg histedit 6 --commands - << EOF
197 > pick b346ab9a313d 6 c
198 > drop 59d9f330561f 7 d
199 > pick cacdfd884a93 8 f
200 > EOF
201 $ hg log --graph
202 @ 11:c13eb81022ca f
203 |
204 o 6:b346ab9a313d c
205 |
206 o 0:cb9a9f314b8b a
207
208 check hidden revision are ignored (6 have hidden children 7 and 8)
209
210 $ hg histedit 6 --commands - << EOF
211 > pick b346ab9a313d 6 c
212 > pick c13eb81022ca 8 f
213 > EOF
214
215
216
217 Test that rewriting leaving instability behind is allowed
218 ---------------------------------------------------------------------
219
220 $ hg up '.^'
221 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
222 $ hg log -r 'children(.)'
223 11:c13eb81022ca f (no-eol)
224 $ hg histedit -r '.' --commands - <<EOF
225 > edit b346ab9a313d 6 c
226 > EOF
227 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
228 Editing (b346ab9a313d), commit as needed now to split the change
229 (to edit b346ab9a313d, `hg histedit --continue` after making changes)
230 [240]
231 $ echo c >> c
232 $ hg histedit --continue
233 1 new orphan changesets
234
235 $ hg log -r 'orphan()'
236 11:c13eb81022ca f (no-eol)
237
238 stabilise
239
240 $ hg rebase -r 'orphan()' -d .
241 rebasing 11:c13eb81022ca "f"
242 $ hg up tip -q
243
244 Test dropping of changeset on the top of the stack
245 -------------------------------------------------------
246
247 Nothing is rewritten below, the working directory parent must be change for the
248 dropped changeset to be hidden.
249
250 $ cd ..
251 $ hg clone base droplast
252 updating to branch default
253 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
254 $ cd droplast
255 $ hg histedit -r '40db8afa467b' --commands - << EOF
256 > pick 40db8afa467b 10 c
257 > drop b449568bf7fc 11 f
258 > EOF
259 $ hg log -G
260 @ 12:40db8afa467b c
261 |
262 o 0:cb9a9f314b8b a
263
264
265 With rewritten ancestors
266
267 $ echo e > e
268 $ hg add e
269 $ hg commit -m g
270 $ echo f > f
271 $ hg add f
272 $ hg commit -m h
273 $ hg histedit -r '40db8afa467b' --commands - << EOF
274 > pick 47a8561c0449 12 g
275 > pick 40db8afa467b 10 c
276 > drop 1b3b05f35ff0 13 h
277 > EOF
278 $ hg log -G
279 @ 17:ee6544123ab8 c
280 |
281 o 16:269e713e9eae g
282 |
283 o 0:cb9a9f314b8b a
284
285 $ cd ../base
286
287
288
289 Test phases support
290 ===========================================
291
292 Check that histedit respect immutability
293 -------------------------------------------
294
295 $ cat >> $HGRCPATH << EOF
296 > [command-templates]
297 > log = {rev}:{node|short} ({phase}) {desc|firstline}\n
298 > EOF
299
300 $ hg ph -pv '.^'
301 phase changed for 2 changesets
302 $ hg log -G
303 @ 13:b449568bf7fc (draft) f
304 |
305 o 12:40db8afa467b (public) c
306 |
307 o 0:cb9a9f314b8b (public) a
308
309 $ hg histedit -r '.~2'
310 abort: cannot edit public changesets: cb9a9f314b8b, 40db8afa467b
311 (see 'hg help phases' for details)
312 [10]
313
314
315 Prepare further testing
316 -------------------------------------------
317
318 $ for x in g h i j k ; do
319 > echo $x > $x
320 > hg add $x
321 > hg ci -m $x
322 > done
323 $ hg phase --force --secret .~2
324 $ hg log -G
325 @ 18:ee118ab9fa44 (secret) k
326 |
327 o 17:3a6c53ee7f3d (secret) j
328 |
329 o 16:b605fb7503f2 (secret) i
330 |
331 o 15:7395e1ff83bd (draft) h
332 |
333 o 14:6b70183d2492 (draft) g
334 |
335 o 13:b449568bf7fc (draft) f
336 |
337 o 12:40db8afa467b (public) c
338 |
339 o 0:cb9a9f314b8b (public) a
340
341 $ cd ..
342
343 simple phase conservation
344 -------------------------------------------
345
346 Resulting changeset should conserve the phase of the original one whatever the
347 phases.new-commit option is.
348
349 New-commit as draft (default)
350
351 $ cp -R base simple-draft
352 $ cd simple-draft
353 $ hg histedit -r 'b449568bf7fc' --commands - << EOF
354 > edit b449568bf7fc 11 f
355 > pick 6b70183d2492 12 g
356 > pick 7395e1ff83bd 13 h
357 > pick b605fb7503f2 14 i
358 > pick 3a6c53ee7f3d 15 j
359 > pick ee118ab9fa44 16 k
360 > EOF
361 0 files updated, 0 files merged, 6 files removed, 0 files unresolved
362 Editing (b449568bf7fc), commit as needed now to split the change
363 (to edit b449568bf7fc, `hg histedit --continue` after making changes)
364 [240]
365 $ echo f >> f
366 $ hg continue
367 $ hg log -G
368 @ 24:12e89af74238 (secret) k
369 |
370 o 23:636a8687b22e (secret) j
371 |
372 o 22:ccaf0a38653f (secret) i
373 |
374 o 21:11a89d1c2613 (draft) h
375 |
376 o 20:c1dec7ca82ea (draft) g
377 |
378 o 19:087281e68428 (draft) f
379 |
380 o 12:40db8afa467b (public) c
381 |
382 o 0:cb9a9f314b8b (public) a
383
384 $ cd ..
385
386
387 New-commit as secret (config)
388
389 $ cp -R base simple-secret
390 $ cd simple-secret
391 $ cat >> .hg/hgrc << EOF
392 > [phases]
393 > new-commit=secret
394 > EOF
395 $ hg histedit -r 'b449568bf7fc' --commands - << EOF
396 > edit b449568bf7fc 11 f
397 > pick 6b70183d2492 12 g
398 > pick 7395e1ff83bd 13 h
399 > pick b605fb7503f2 14 i
400 > pick 3a6c53ee7f3d 15 j
401 > pick ee118ab9fa44 16 k
402 > EOF
403 0 files updated, 0 files merged, 6 files removed, 0 files unresolved
404 Editing (b449568bf7fc), commit as needed now to split the change
405 (to edit b449568bf7fc, `hg histedit --continue` after making changes)
406 [240]
407 $ echo f >> f
408 $ hg histedit --continue
409 $ hg log -G
410 @ 24:12e89af74238 (secret) k
411 |
412 o 23:636a8687b22e (secret) j
413 |
414 o 22:ccaf0a38653f (secret) i
415 |
416 o 21:11a89d1c2613 (draft) h
417 |
418 o 20:c1dec7ca82ea (draft) g
419 |
420 o 19:087281e68428 (draft) f
421 |
422 o 12:40db8afa467b (public) c
423 |
424 o 0:cb9a9f314b8b (public) a
425
426 $ cd ..
427
428
429 Changeset reordering
430 -------------------------------------------
431
432 If a secret changeset is put before a draft one, all descendant should be secret.
433 It seems more important to present the secret phase.
434
435 $ cp -R base reorder
436 $ cd reorder
437 $ hg histedit -r 'b449568bf7fc' --commands - << EOF
438 > pick b449568bf7fc 11 f
439 > pick 3a6c53ee7f3d 15 j
440 > pick 6b70183d2492 12 g
441 > pick b605fb7503f2 14 i
442 > pick 7395e1ff83bd 13 h
443 > pick ee118ab9fa44 16 k
444 > EOF
445 $ hg log -G
446 @ 23:558246857888 (secret) k
447 |
448 o 22:28bd44768535 (secret) h
449 |
450 o 21:d5395202aeb9 (secret) i
451 |
452 o 20:21edda8e341b (secret) g
453 |
454 o 19:5ab64f3a4832 (secret) j
455 |
456 o 13:b449568bf7fc (draft) f
457 |
458 o 12:40db8afa467b (public) c
459 |
460 o 0:cb9a9f314b8b (public) a
461
462 $ cd ..
463
464 Changeset folding
465 -------------------------------------------
466
467 Folding a secret changeset with a draft one turn the result secret (again,
468 better safe than sorry). Folding between same phase changeset still works
469
470 Note that there is a few reordering in this series for more extensive test
471
472 $ cp -R base folding
473 $ cd folding
474 $ cat >> .hg/hgrc << EOF
475 > [phases]
476 > new-commit=secret
477 > EOF
478 $ hg histedit -r 'b449568bf7fc' --commands - << EOF
479 > pick 7395e1ff83bd 13 h
480 > fold b449568bf7fc 11 f
481 > pick 6b70183d2492 12 g
482 > fold 3a6c53ee7f3d 15 j
483 > pick b605fb7503f2 14 i
484 > fold ee118ab9fa44 16 k
485 > EOF
486 $ hg log -G
487 @ 27:f9daec13fb98 (secret) i
488 |
489 o 24:49807617f46a (secret) g
490 |
491 o 21:050280826e04 (draft) h
492 |
493 o 12:40db8afa467b (public) c
494 |
495 o 0:cb9a9f314b8b (public) a
496
497 $ hg co 49807617f46a
498 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
499 $ echo wat >> wat
500 $ hg add wat
501 $ hg ci -m 'add wat'
502 created new head
503 $ hg merge f9daec13fb98
504 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
505 (branch merge, don't forget to commit)
506 $ hg ci -m 'merge'
507 $ echo not wat > wat
508 $ hg ci -m 'modify wat'
509 $ hg histedit 050280826e04
510 abort: cannot edit history that contains merges
511 [20]
512 $ cd ..
513
514 Check abort behavior
515 -------------------------------------------
516
517 We checks that abort properly clean the repository so the same histedit can be
518 attempted later.
519
520 $ cp -R base abort
521 $ cd abort
522 $ hg histedit -r 'b449568bf7fc' --commands - << EOF
523 > pick b449568bf7fc 13 f
524 > pick 7395e1ff83bd 15 h
525 > pick 6b70183d2492 14 g
526 > pick b605fb7503f2 16 i
527 > roll 3a6c53ee7f3d 17 j
528 > edit ee118ab9fa44 18 k
529 > EOF
530 Editing (ee118ab9fa44), commit as needed now to split the change
531 (to edit ee118ab9fa44, `hg histedit --continue` after making changes)
532 [240]
533
534 #if abortcommand
535 when in dry-run mode
536 $ hg abort --dry-run
537 histedit in progress, will be aborted
538 #endif
539
540 $ hg abort
541 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
542 saved backup bundle to $TESTTMP/abort/.hg/strip-backup/4dc06258baa6-dff4ef05-backup.hg
543
544 $ hg log -G
545 @ 18:ee118ab9fa44 (secret) k
546 |
547 o 17:3a6c53ee7f3d (secret) j
548 |
549 o 16:b605fb7503f2 (secret) i
550 |
551 o 15:7395e1ff83bd (draft) h
552 |
553 o 14:6b70183d2492 (draft) g
554 |
555 o 13:b449568bf7fc (draft) f
556 |
557 o 12:40db8afa467b (public) c
558 |
559 o 0:cb9a9f314b8b (public) a
560
561 $ hg histedit -r 'b449568bf7fc' --commands - << EOF --config experimental.evolution.track-operation=1
562 > pick b449568bf7fc 13 f
563 > pick 7395e1ff83bd 15 h
564 > pick 6b70183d2492 14 g
565 > pick b605fb7503f2 16 i
566 > pick 3a6c53ee7f3d 17 j
567 > edit ee118ab9fa44 18 k
568 > EOF
569 Editing (ee118ab9fa44), commit as needed now to split the change
570 (to edit ee118ab9fa44, `hg histedit --continue` after making changes)
571 [240]
572 $ hg continue --config experimental.evolution.track-operation=1
573 $ hg log -G
574 @ 23:175d6b286a22 (secret) k
575 |
576 o 22:44ca09d59ae4 (secret) j
577 |
578 o 21:31747692a644 (secret) i
579 |
580 o 20:9985cd4f21fa (draft) g
581 |
582 o 19:4dc06258baa6 (draft) h
583 |
584 o 13:b449568bf7fc (draft) f
585 |
586 o 12:40db8afa467b (public) c
587 |
588 o 0:cb9a9f314b8b (public) a
589
590 $ hg debugobsolete --rev .
591 ee118ab9fa44ebb86be85996548b5517a39e5093 175d6b286a224c23f192e79a581ce83131a53fa2 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'histedit', 'user': 'test'}