Debian Codegraph @

tests/test-histedit-commute.t

raw
1 $ . "$TESTDIR/histedit-helpers.sh"
2
3 $ cat >> $HGRCPATH <<EOF
4 > [extensions]
5 > histedit=
6 > EOF
7
8 $ initrepo ()
9 > {
10 > hg init r
11 > cd r
12 > for x in a b c d e f ; do
13 > echo $x > $x
14 > hg add $x
15 > hg ci -m $x
16 > done
17 > }
18
19 $ initrepo
20
21 log before edit
22 $ hg log --graph
23 @ changeset: 5:652413bf663e
24 | tag: tip
25 | user: test
26 | date: Thu Jan 01 00:00:00 1970 +0000
27 | summary: f
28 |
29 o changeset: 4:e860deea161a
30 | user: test
31 | date: Thu Jan 01 00:00:00 1970 +0000
32 | summary: e
33 |
34 o changeset: 3:055a42cdd887
35 | user: test
36 | date: Thu Jan 01 00:00:00 1970 +0000
37 | summary: d
38 |
39 o changeset: 2:177f92b77385
40 | user: test
41 | date: Thu Jan 01 00:00:00 1970 +0000
42 | summary: c
43 |
44 o changeset: 1:d2ae7f538514
45 | user: test
46 | date: Thu Jan 01 00:00:00 1970 +0000
47 | summary: b
48 |
49 o changeset: 0:cb9a9f314b8b
50 user: test
51 date: Thu Jan 01 00:00:00 1970 +0000
52 summary: a
53
54
55
56 show the edit commands offered
57 $ HGEDITOR=cat hg histedit 177f92b77385
58 pick 177f92b77385 2 c
59 pick 055a42cdd887 3 d
60 pick e860deea161a 4 e
61 pick 652413bf663e 5 f
62
63 # Edit history between 177f92b77385 and 652413bf663e
64 #
65 # Commits are listed from least to most recent
66 #
67 # You can reorder changesets by reordering the lines
68 #
69 # Commands:
70 #
71 # e, edit = use commit, but allow edits before making new commit
72 # m, mess = edit commit message without changing commit content
73 # p, pick = use commit
74 # b, base = checkout changeset and apply further changesets from there
75 # d, drop = remove commit from history
76 # f, fold = use commit, but combine it with the one above
77 # r, roll = like fold, but discard this commit's description and date
78 #
79
80
81 test customization of revision summary
82 $ HGEDITOR=cat hg histedit 177f92b77385 \
83 > --config histedit.summary-template='I am rev {rev} desc {desc} tags {tags}'
84 pick 177f92b77385 I am rev 2 desc c tags
85 pick 055a42cdd887 I am rev 3 desc d tags
86 pick e860deea161a I am rev 4 desc e tags
87 pick 652413bf663e I am rev 5 desc f tags tip
88
89 # Edit history between 177f92b77385 and 652413bf663e
90 #
91 # Commits are listed from least to most recent
92 #
93 # You can reorder changesets by reordering the lines
94 #
95 # Commands:
96 #
97 # e, edit = use commit, but allow edits before making new commit
98 # m, mess = edit commit message without changing commit content
99 # p, pick = use commit
100 # b, base = checkout changeset and apply further changesets from there
101 # d, drop = remove commit from history
102 # f, fold = use commit, but combine it with the one above
103 # r, roll = like fold, but discard this commit's description and date
104 #
105
106
107 colors in the custom template don't show up in the editor
108 $ HGEDITOR=cat hg histedit 177f92b77385 --color=debug \
109 > --config histedit.summary-template='I am rev {label("rev", rev)}'
110 pick 177f92b77385 I am rev 2
111 pick 055a42cdd887 I am rev 3
112 pick e860deea161a I am rev 4
113 pick 652413bf663e I am rev 5
114
115 # Edit history between 177f92b77385 and 652413bf663e
116 #
117 # Commits are listed from least to most recent
118 #
119 # You can reorder changesets by reordering the lines
120 #
121 # Commands:
122 #
123 # e, edit = use commit, but allow edits before making new commit
124 # m, mess = edit commit message without changing commit content
125 # p, pick = use commit
126 # b, base = checkout changeset and apply further changesets from there
127 # d, drop = remove commit from history
128 # f, fold = use commit, but combine it with the one above
129 # r, roll = like fold, but discard this commit's description and date
130 #
131
132
133 edit the history
134 (use a hacky editor to check histedit-last-edit.txt backup)
135
136 $ EDITED="$TESTTMP/editedhistory"
137 $ cat > $EDITED <<EOF
138 > edit 177f92b77385 c
139 > pick e860deea161a e
140 > pick 652413bf663e f
141 > pick 055a42cdd887 d
142 > EOF
143 $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
144 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
145 Editing (177f92b77385), commit as needed now to split the change
146 (to edit 177f92b77385, `hg histedit --continue` after making changes)
147
148 rules should end up in .hg/histedit-last-edit.txt:
149 $ cat .hg/histedit-last-edit.txt
150 edit 177f92b77385 c
151 pick e860deea161a e
152 pick 652413bf663e f
153 pick 055a42cdd887 d
154
155 $ hg histedit --abort
156 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
157 $ cat > $EDITED <<EOF
158 > pick 177f92b77385 c
159 > pick e860deea161a e
160 > pick 652413bf663e f
161 > pick 055a42cdd887 d
162 > EOF
163 $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
164
165 log after edit
166 $ hg log --graph
167 @ changeset: 5:07114f51870f
168 | tag: tip
169 | user: test
170 | date: Thu Jan 01 00:00:00 1970 +0000
171 | summary: d
172 |
173 o changeset: 4:8ade9693061e
174 | user: test
175 | date: Thu Jan 01 00:00:00 1970 +0000
176 | summary: f
177 |
178 o changeset: 3:d8249471110a
179 | user: test
180 | date: Thu Jan 01 00:00:00 1970 +0000
181 | summary: e
182 |
183 o changeset: 2:177f92b77385
184 | user: test
185 | date: Thu Jan 01 00:00:00 1970 +0000
186 | summary: c
187 |
188 o changeset: 1:d2ae7f538514
189 | user: test
190 | date: Thu Jan 01 00:00:00 1970 +0000
191 | summary: b
192 |
193 o changeset: 0:cb9a9f314b8b
194 user: test
195 date: Thu Jan 01 00:00:00 1970 +0000
196 summary: a
197
198
199
200 put things back
201
202 $ hg histedit 177f92b77385 --commands - 2>&1 << EOF | fixbundle
203 > pick 177f92b77385 c
204 > pick 07114f51870f d
205 > pick d8249471110a e
206 > pick 8ade9693061e f
207 > EOF
208
209 $ hg log --graph
210 @ changeset: 5:7eca9b5b1148
211 | tag: tip
212 | user: test
213 | date: Thu Jan 01 00:00:00 1970 +0000
214 | summary: f
215 |
216 o changeset: 4:915da888f2de
217 | user: test
218 | date: Thu Jan 01 00:00:00 1970 +0000
219 | summary: e
220 |
221 o changeset: 3:10517e47bbbb
222 | user: test
223 | date: Thu Jan 01 00:00:00 1970 +0000
224 | summary: d
225 |
226 o changeset: 2:177f92b77385
227 | user: test
228 | date: Thu Jan 01 00:00:00 1970 +0000
229 | summary: c
230 |
231 o changeset: 1:d2ae7f538514
232 | user: test
233 | date: Thu Jan 01 00:00:00 1970 +0000
234 | summary: b
235 |
236 o changeset: 0:cb9a9f314b8b
237 user: test
238 date: Thu Jan 01 00:00:00 1970 +0000
239 summary: a
240
241
242
243 slightly different this time
244
245 $ hg histedit 177f92b77385 --commands - << EOF 2>&1 | fixbundle
246 > pick 10517e47bbbb d
247 > pick 7eca9b5b1148 f
248 > pick 915da888f2de e
249 > pick 177f92b77385 c
250 > EOF
251 $ hg log --graph
252 @ changeset: 5:38b92f448761
253 | tag: tip
254 | user: test
255 | date: Thu Jan 01 00:00:00 1970 +0000
256 | summary: c
257 |
258 o changeset: 4:de71b079d9ce
259 | user: test
260 | date: Thu Jan 01 00:00:00 1970 +0000
261 | summary: e
262 |
263 o changeset: 3:be9ae3a309c6
264 | user: test
265 | date: Thu Jan 01 00:00:00 1970 +0000
266 | summary: f
267 |
268 o changeset: 2:799205341b6b
269 | user: test
270 | date: Thu Jan 01 00:00:00 1970 +0000
271 | summary: d
272 |
273 o changeset: 1:d2ae7f538514
274 | user: test
275 | date: Thu Jan 01 00:00:00 1970 +0000
276 | summary: b
277 |
278 o changeset: 0:cb9a9f314b8b
279 user: test
280 date: Thu Jan 01 00:00:00 1970 +0000
281 summary: a
282
283
284
285 keep prevents stripping dead revs
286 $ hg histedit 799205341b6b --keep --commands - 2>&1 << EOF | fixbundle
287 > pick 799205341b6b d
288 > pick be9ae3a309c6 f
289 > pick 38b92f448761 c
290 > pick de71b079d9ce e
291 > EOF
292 $ hg log --graph
293 @ changeset: 7:803ef1c6fcfd
294 | tag: tip
295 | user: test
296 | date: Thu Jan 01 00:00:00 1970 +0000
297 | summary: e
298 |
299 o changeset: 6:ece0b8d93dda
300 | parent: 3:be9ae3a309c6
301 | user: test
302 | date: Thu Jan 01 00:00:00 1970 +0000
303 | summary: c
304 |
305 | o changeset: 5:38b92f448761
306 | | user: test
307 | | date: Thu Jan 01 00:00:00 1970 +0000
308 | | summary: c
309 | |
310 | o changeset: 4:de71b079d9ce
311 |/ user: test
312 | date: Thu Jan 01 00:00:00 1970 +0000
313 | summary: e
314 |
315 o changeset: 3:be9ae3a309c6
316 | user: test
317 | date: Thu Jan 01 00:00:00 1970 +0000
318 | summary: f
319 |
320 o changeset: 2:799205341b6b
321 | user: test
322 | date: Thu Jan 01 00:00:00 1970 +0000
323 | summary: d
324 |
325 o changeset: 1:d2ae7f538514
326 | user: test
327 | date: Thu Jan 01 00:00:00 1970 +0000
328 | summary: b
329 |
330 o changeset: 0:cb9a9f314b8b
331 user: test
332 date: Thu Jan 01 00:00:00 1970 +0000
333 summary: a
334
335
336
337 try with --rev
338 $ hg histedit --commands - --rev -2 2>&1 <<EOF | fixbundle
339 > pick de71b079d9ce e
340 > pick 38b92f448761 c
341 > EOF
342 hg: parse error: pick "de71b079d9ce" changeset was not a candidate
343 (only use listed changesets)
344 $ hg log --graph
345 @ changeset: 7:803ef1c6fcfd
346 | tag: tip
347 | user: test
348 | date: Thu Jan 01 00:00:00 1970 +0000
349 | summary: e
350 |
351 o changeset: 6:ece0b8d93dda
352 | parent: 3:be9ae3a309c6
353 | user: test
354 | date: Thu Jan 01 00:00:00 1970 +0000
355 | summary: c
356 |
357 | o changeset: 5:38b92f448761
358 | | user: test
359 | | date: Thu Jan 01 00:00:00 1970 +0000
360 | | summary: c
361 | |
362 | o changeset: 4:de71b079d9ce
363 |/ user: test
364 | date: Thu Jan 01 00:00:00 1970 +0000
365 | summary: e
366 |
367 o changeset: 3:be9ae3a309c6
368 | user: test
369 | date: Thu Jan 01 00:00:00 1970 +0000
370 | summary: f
371 |
372 o changeset: 2:799205341b6b
373 | user: test
374 | date: Thu Jan 01 00:00:00 1970 +0000
375 | summary: d
376 |
377 o changeset: 1:d2ae7f538514
378 | user: test
379 | date: Thu Jan 01 00:00:00 1970 +0000
380 | summary: b
381 |
382 o changeset: 0:cb9a9f314b8b
383 user: test
384 date: Thu Jan 01 00:00:00 1970 +0000
385 summary: a
386
387
388 Verify that revsetalias entries work with histedit:
389 $ cat >> $HGRCPATH <<EOF
390 > [revsetalias]
391 > grandparent(ARG) = p1(p1(ARG))
392 > EOF
393 $ echo extra commit >> c
394 $ hg ci -m 'extra commit to c'
395 $ HGEDITOR=cat hg histedit 'grandparent(.)'
396 pick ece0b8d93dda 6 c
397 pick 803ef1c6fcfd 7 e
398 pick 9c863c565126 8 extra commit to c
399
400 # Edit history between ece0b8d93dda and 9c863c565126
401 #
402 # Commits are listed from least to most recent
403 #
404 # You can reorder changesets by reordering the lines
405 #
406 # Commands:
407 #
408 # e, edit = use commit, but allow edits before making new commit
409 # m, mess = edit commit message without changing commit content
410 # p, pick = use commit
411 # b, base = checkout changeset and apply further changesets from there
412 # d, drop = remove commit from history
413 # f, fold = use commit, but combine it with the one above
414 # r, roll = like fold, but discard this commit's description and date
415 #
416
417
418 should also work if a commit message is missing
419 $ BUNDLE="$TESTDIR/missing-comment.hg"
420 $ hg init missing
421 $ cd missing
422 $ hg unbundle $BUNDLE
423 adding changesets
424 adding manifests
425 adding file changes
426 added 3 changesets with 3 changes to 1 files
427 new changesets 141947992243:bd22688093b3 (3 drafts)
428 (run 'hg update' to get a working copy)
429 $ hg co tip
430 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
431 $ hg log --graph
432 @ changeset: 2:bd22688093b3
433 | tag: tip
434 | user: Robert Altman <[email protected]>
435 | date: Mon Nov 28 16:40:04 2011 +0000
436 | summary: Update file.
437 |
438 o changeset: 1:3b3e956f9171
439 | user: Robert Altman <[email protected]>
440 | date: Mon Nov 28 16:37:57 2011 +0000
441 |
442 o changeset: 0:141947992243
443 user: Robert Altman <[email protected]>
444 date: Mon Nov 28 16:35:28 2011 +0000
445 summary: Checked in text file
446
447
448 $ hg histedit 0
449 $ cd ..
450
451 $ cd ..
452
453
454 Test to make sure folding renames doesn't cause bogus conflicts (issue4251):
455 $ hg init issue4251
456 $ cd issue4251
457
458 $ mkdir initial-dir
459 $ echo foo > initial-dir/initial-file
460 $ hg add initial-dir/initial-file
461 $ hg commit -m "initial commit"
462
463 Move the file to a new directory, and in the same commit, change its content:
464 $ mkdir another-dir
465 $ hg mv initial-dir/initial-file another-dir/
466 $ echo changed > another-dir/initial-file
467 $ hg commit -m "moved and changed"
468
469 Rename the file:
470 $ hg mv another-dir/initial-file another-dir/renamed-file
471 $ hg commit -m "renamed"
472
473 Now, let's try to fold the second commit into the first:
474 $ cat > editor.sh <<EOF
475 > #!/bin/sh
476 > cat > \$1 <<ENDOF
477 > pick b0f4233702ca 0 initial commit
478 > fold 5e8704a8f2d2 1 moved and changed
479 > pick 40e7299e8fa7 2 renamed
480 > ENDOF
481 > EOF
482
483 $ HGEDITOR="sh ./editor.sh" hg histedit 0
484 saved backup bundle to $TESTTMP/issue4251/.hg/strip-backup/b0f4233702ca-4cf5af69-histedit.hg
485
486 $ hg --config diff.git=yes export 0
487 # HG changeset patch
488 # User test
489 # Date 0 0
490 # Thu Jan 01 00:00:00 1970 +0000
491 # Node ID fffadc26f8f85623ce60b028a3f1ccc3730f8530
492 # Parent 0000000000000000000000000000000000000000
493 pick b0f4233702ca 0 initial commit
494 fold 5e8704a8f2d2 1 moved and changed
495 pick 40e7299e8fa7 2 renamed
496
497 diff --git a/another-dir/initial-file b/another-dir/initial-file
498 new file mode 100644
499 --- /dev/null
500 +++ b/another-dir/initial-file
501 @@ -0,0 +1,1 @@
502 +changed
503
504
505 $ hg --config diff.git=yes export 1
506 # HG changeset patch
507 # User test
508 # Date 0 0
509 # Thu Jan 01 00:00:00 1970 +0000
510 # Node ID 9b730d82b00af8a2766facebfa47cc124405a118
511 # Parent fffadc26f8f85623ce60b028a3f1ccc3730f8530
512 renamed
513
514 diff --git a/another-dir/initial-file b/another-dir/renamed-file
515 rename from another-dir/initial-file
516 rename to another-dir/renamed-file
517
518
519 $ cd ..
520
521 Test that branches are preserved and stays active
522 -------------------------------------------------
523
524 $ hg init repo-with-branch
525 $ cd repo-with-branch
526 $ echo a > a
527 $ hg add a
528 $ hg commit -m A
529 $ hg branch foo
530 marked working directory as branch foo
531 (branches are permanent and global, did you want a bookmark?)
532 $ echo a > b
533 $ hg add b
534 $ hg commit -m foo-B
535 $ echo a > c
536 $ hg add c
537 $ hg commit -m foo-C
538
539 $ hg branch
540 foo
541 $ echo "pick efefa76d6dc3 2 foo-C" >> cmd
542 $ echo "pick 7336e7550422 1 foo-B" >> cmd
543
544 $ HGEDITOR=cat hg histedit -r ".^" --commands cmd --quiet
545 $ hg log --template '{rev} {branch}\n'
546 2 foo
547 1 foo
548 0 default
549 $ hg branch
550 foo
551
552 $ cd ..