##// END OF EJS Templates
test-histedit-edit: test histedit with dirty repo
timeless -
r27544:a4f00861 default
parent child Browse files
Show More
@@ -1,471 +1,478 b''
1 1 $ . "$TESTDIR/histedit-helpers.sh"
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > histedit=
6 6 > strip=
7 7 > EOF
8 8
9 9 $ initrepo ()
10 10 > {
11 11 > hg init r
12 12 > cd r
13 13 > for x in a b c d e f g; do
14 14 > echo $x > $x
15 15 > hg add $x
16 16 > hg ci -m $x
17 17 > done
18 18 > }
19 19
20 20 $ initrepo
21 21
22 22 log before edit
23 23 $ hg log --graph
24 24 @ changeset: 6:3c6a8ed2ebe8
25 25 | tag: tip
26 26 | user: test
27 27 | date: Thu Jan 01 00:00:00 1970 +0000
28 28 | summary: g
29 29 |
30 30 o changeset: 5:652413bf663e
31 31 | user: test
32 32 | date: Thu Jan 01 00:00:00 1970 +0000
33 33 | summary: f
34 34 |
35 35 o changeset: 4:e860deea161a
36 36 | user: test
37 37 | date: Thu Jan 01 00:00:00 1970 +0000
38 38 | summary: e
39 39 |
40 40 o changeset: 3:055a42cdd887
41 41 | user: test
42 42 | date: Thu Jan 01 00:00:00 1970 +0000
43 43 | summary: d
44 44 |
45 45 o changeset: 2:177f92b77385
46 46 | user: test
47 47 | date: Thu Jan 01 00:00:00 1970 +0000
48 48 | summary: c
49 49 |
50 50 o changeset: 1:d2ae7f538514
51 51 | user: test
52 52 | date: Thu Jan 01 00:00:00 1970 +0000
53 53 | summary: b
54 54 |
55 55 o changeset: 0:cb9a9f314b8b
56 56 user: test
57 57 date: Thu Jan 01 00:00:00 1970 +0000
58 58 summary: a
59 59
60 dirty a file
61 $ echo a > g
62 $ hg histedit 177f92b77385 --commands - 2>&1 << EOF
63 > EOF
64 abort: uncommitted changes
65 [255]
66 $ echo g > g
60 67
61 68 edit the history
62 69 $ hg histedit 177f92b77385 --commands - 2>&1 << EOF| fixbundle
63 70 > pick 177f92b77385 c
64 71 > pick 055a42cdd887 d
65 72 > edit e860deea161a e
66 73 > pick 652413bf663e f
67 74 > pick 3c6a8ed2ebe8 g
68 75 > EOF
69 76 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
70 77 Make changes as needed, you may commit or record as needed now.
71 78 When you are finished, run hg histedit --continue to resume.
72 79
73 80 edit the plan via the editor
74 81 $ cat >> $TESTTMP/editplan.sh <<EOF
75 82 > cat > \$1 <<EOF2
76 83 > drop e860deea161a e
77 84 > drop 652413bf663e f
78 85 > drop 3c6a8ed2ebe8 g
79 86 > EOF2
80 87 > EOF
81 88 $ HGEDITOR="sh $TESTTMP/editplan.sh" hg histedit --edit-plan
82 89 $ cat .hg/histedit-state
83 90 v1
84 91 055a42cdd88768532f9cf79daa407fc8d138de9b
85 92 3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
86 93 False
87 94 3
88 95 drop
89 96 e860deea161a2f77de56603b340ebbb4536308ae
90 97 drop
91 98 652413bf663ef2a641cab26574e46d5f5a64a55a
92 99 drop
93 100 3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
94 101 0
95 102 strip-backup/177f92b77385-0ebe6a8f-histedit.hg
96 103
97 104 edit the plan via --commands
98 105 $ hg histedit --edit-plan --commands - 2>&1 << EOF
99 106 > edit e860deea161a e
100 107 > pick 652413bf663e f
101 108 > drop 3c6a8ed2ebe8 g
102 109 > EOF
103 110 $ cat .hg/histedit-state
104 111 v1
105 112 055a42cdd88768532f9cf79daa407fc8d138de9b
106 113 3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
107 114 False
108 115 3
109 116 edit
110 117 e860deea161a2f77de56603b340ebbb4536308ae
111 118 pick
112 119 652413bf663ef2a641cab26574e46d5f5a64a55a
113 120 drop
114 121 3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
115 122 0
116 123 strip-backup/177f92b77385-0ebe6a8f-histedit.hg
117 124
118 125 Go at a random point and try to continue
119 126
120 127 $ hg id -n
121 128 3+
122 129 $ hg up 0
123 130 abort: histedit in progress
124 131 (use 'hg histedit --continue' or 'hg histedit --abort')
125 132 [255]
126 133
127 134 Try to delete necessary commit
128 135 $ hg strip -r 652413b
129 136 abort: histedit in progress, can't strip 652413bf663e
130 137 [255]
131 138
132 139 commit, then edit the revision
133 140 $ hg ci -m 'wat'
134 141 created new head
135 142 $ echo a > e
136 143
137 144 qnew should fail while we're in the middle of the edit step
138 145
139 146 $ hg --config extensions.mq= qnew please-fail
140 147 abort: histedit in progress
141 148 (use 'hg histedit --continue' or 'hg histedit --abort')
142 149 [255]
143 150 $ HGEDITOR='echo foobaz > ' hg histedit --continue 2>&1 | fixbundle
144 151
145 152 $ hg log --graph
146 153 @ changeset: 6:b5f70786f9b0
147 154 | tag: tip
148 155 | user: test
149 156 | date: Thu Jan 01 00:00:00 1970 +0000
150 157 | summary: f
151 158 |
152 159 o changeset: 5:a5e1ba2f7afb
153 160 | user: test
154 161 | date: Thu Jan 01 00:00:00 1970 +0000
155 162 | summary: foobaz
156 163 |
157 164 o changeset: 4:1a60820cd1f6
158 165 | user: test
159 166 | date: Thu Jan 01 00:00:00 1970 +0000
160 167 | summary: wat
161 168 |
162 169 o changeset: 3:055a42cdd887
163 170 | user: test
164 171 | date: Thu Jan 01 00:00:00 1970 +0000
165 172 | summary: d
166 173 |
167 174 o changeset: 2:177f92b77385
168 175 | user: test
169 176 | date: Thu Jan 01 00:00:00 1970 +0000
170 177 | summary: c
171 178 |
172 179 o changeset: 1:d2ae7f538514
173 180 | user: test
174 181 | date: Thu Jan 01 00:00:00 1970 +0000
175 182 | summary: b
176 183 |
177 184 o changeset: 0:cb9a9f314b8b
178 185 user: test
179 186 date: Thu Jan 01 00:00:00 1970 +0000
180 187 summary: a
181 188
182 189
183 190 $ hg cat e
184 191 a
185 192
186 193 Stripping necessary commits should not break --abort
187 194
188 195 $ hg histedit 1a60820cd1f6 --commands - 2>&1 << EOF| fixbundle
189 196 > edit 1a60820cd1f6 wat
190 197 > pick a5e1ba2f7afb foobaz
191 198 > pick b5f70786f9b0 g
192 199 > EOF
193 200 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
194 201 Make changes as needed, you may commit or record as needed now.
195 202 When you are finished, run hg histedit --continue to resume.
196 203
197 204 $ mv .hg/histedit-state .hg/histedit-state.bak
198 205 $ hg strip -q -r b5f70786f9b0
199 206 $ mv .hg/histedit-state.bak .hg/histedit-state
200 207 $ hg histedit --abort
201 208 adding changesets
202 209 adding manifests
203 210 adding file changes
204 211 added 1 changesets with 1 changes to 3 files
205 212 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
206 213 $ hg log -r .
207 214 changeset: 6:b5f70786f9b0
208 215 tag: tip
209 216 user: test
210 217 date: Thu Jan 01 00:00:00 1970 +0000
211 218 summary: f
212 219
213 220
214 221 check histedit_source
215 222
216 223 $ hg log --debug --rev 5
217 224 changeset: 5:a5e1ba2f7afb899ef1581cea528fd885d2fca70d
218 225 phase: draft
219 226 parent: 4:1a60820cd1f6004a362aa622ebc47d59bc48eb34
220 227 parent: -1:0000000000000000000000000000000000000000
221 228 manifest: 5:5ad3be8791f39117565557781f5464363b918a45
222 229 user: test
223 230 date: Thu Jan 01 00:00:00 1970 +0000
224 231 files: e
225 232 extra: branch=default
226 233 extra: histedit_source=e860deea161a2f77de56603b340ebbb4536308ae
227 234 description:
228 235 foobaz
229 236
230 237
231 238
232 239 $ hg histedit tip --commands - 2>&1 <<EOF| fixbundle
233 240 > edit b5f70786f9b0 f
234 241 > EOF
235 242 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
236 243 Make changes as needed, you may commit or record as needed now.
237 244 When you are finished, run hg histedit --continue to resume.
238 245 $ hg status
239 246 A f
240 247
241 248 $ hg summary
242 249 parent: 5:a5e1ba2f7afb
243 250 foobaz
244 251 branch: default
245 252 commit: 1 added (new branch head)
246 253 update: 1 new changesets (update)
247 254 phases: 7 draft
248 255 hist: 1 remaining (histedit --continue)
249 256
250 257 (test also that editor is invoked if histedit is continued for
251 258 "edit" action)
252 259
253 260 $ HGEDITOR='cat' hg histedit --continue
254 261 f
255 262
256 263
257 264 HG: Enter commit message. Lines beginning with 'HG:' are removed.
258 265 HG: Leave message empty to abort commit.
259 266 HG: --
260 267 HG: user: test
261 268 HG: branch 'default'
262 269 HG: added f
263 270 saved backup bundle to $TESTTMP/r/.hg/strip-backup/b5f70786f9b0-c28d9c86-backup.hg (glob)
264 271
265 272 $ hg status
266 273
267 274 log after edit
268 275 $ hg log --limit 1
269 276 changeset: 6:a107ee126658
270 277 tag: tip
271 278 user: test
272 279 date: Thu Jan 01 00:00:00 1970 +0000
273 280 summary: f
274 281
275 282
276 283 say we'll change the message, but don't.
277 284 $ cat > ../edit.sh <<EOF
278 285 > cat "\$1" | sed s/pick/mess/ > tmp
279 286 > mv tmp "\$1"
280 287 > EOF
281 288 $ HGEDITOR="sh ../edit.sh" hg histedit tip 2>&1 | fixbundle
282 289 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
283 290 $ hg status
284 291 $ hg log --limit 1
285 292 changeset: 6:1fd3b2fe7754
286 293 tag: tip
287 294 user: test
288 295 date: Thu Jan 01 00:00:00 1970 +0000
289 296 summary: f
290 297
291 298
292 299 modify the message
293 300
294 301 check saving last-message.txt, at first
295 302
296 303 $ cat > $TESTTMP/commitfailure.py <<EOF
297 304 > from mercurial import error
298 305 > def reposetup(ui, repo):
299 306 > class commitfailure(repo.__class__):
300 307 > def commit(self, *args, **kwargs):
301 308 > raise error.Abort('emulating unexpected abort')
302 309 > repo.__class__ = commitfailure
303 310 > EOF
304 311 $ cat >> .hg/hgrc <<EOF
305 312 > [extensions]
306 313 > # this failure occurs before editor invocation
307 314 > commitfailure = $TESTTMP/commitfailure.py
308 315 > EOF
309 316
310 317 $ cat > $TESTTMP/editor.sh <<EOF
311 318 > echo "==== before editing"
312 319 > cat \$1
313 320 > echo "===="
314 321 > echo "check saving last-message.txt" >> \$1
315 322 > EOF
316 323
317 324 (test that editor is not invoked before transaction starting)
318 325
319 326 $ rm -f .hg/last-message.txt
320 327 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF | fixbundle
321 328 > mess 1fd3b2fe7754 f
322 329 > EOF
323 330 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
324 331 abort: emulating unexpected abort
325 332 $ test -f .hg/last-message.txt
326 333 [1]
327 334
328 335 $ cat >> .hg/hgrc <<EOF
329 336 > [extensions]
330 337 > commitfailure = !
331 338 > EOF
332 339 $ hg histedit --abort -q
333 340
334 341 (test that editor is invoked and commit message is saved into
335 342 "last-message.txt")
336 343
337 344 $ cat >> .hg/hgrc <<EOF
338 345 > [hooks]
339 346 > # this failure occurs after editor invocation
340 347 > pretxncommit.unexpectedabort = false
341 348 > EOF
342 349
343 350 $ hg status --rev '1fd3b2fe7754^1' --rev 1fd3b2fe7754
344 351 A f
345 352
346 353 $ rm -f .hg/last-message.txt
347 354 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF
348 355 > mess 1fd3b2fe7754 f
349 356 > EOF
350 357 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
351 358 adding f
352 359 ==== before editing
353 360 f
354 361
355 362
356 363 HG: Enter commit message. Lines beginning with 'HG:' are removed.
357 364 HG: Leave message empty to abort commit.
358 365 HG: --
359 366 HG: user: test
360 367 HG: branch 'default'
361 368 HG: added f
362 369 ====
363 370 note: commit message saved in .hg/last-message.txt
364 371 transaction abort!
365 372 rollback completed
366 373 abort: pretxncommit.unexpectedabort hook exited with status 1
367 374 [255]
368 375 $ cat .hg/last-message.txt
369 376 f
370 377
371 378
372 379 check saving last-message.txt
373 380
374 381 (test also that editor is invoked if histedit is continued for "message"
375 382 action)
376 383
377 384 $ HGEDITOR=cat hg histedit --continue
378 385 f
379 386
380 387
381 388 HG: Enter commit message. Lines beginning with 'HG:' are removed.
382 389 HG: Leave message empty to abort commit.
383 390 HG: --
384 391 HG: user: test
385 392 HG: branch 'default'
386 393 HG: added f
387 394 note: commit message saved in .hg/last-message.txt
388 395 transaction abort!
389 396 rollback completed
390 397 abort: pretxncommit.unexpectedabort hook exited with status 1
391 398 [255]
392 399
393 400 $ cat >> .hg/hgrc <<EOF
394 401 > [hooks]
395 402 > pretxncommit.unexpectedabort =
396 403 > EOF
397 404 $ hg histedit --abort -q
398 405
399 406 then, check "modify the message" itself
400 407
401 408 $ hg histedit tip --commands - 2>&1 << EOF | fixbundle
402 409 > mess 1fd3b2fe7754 f
403 410 > EOF
404 411 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
405 412 $ hg status
406 413 $ hg log --limit 1
407 414 changeset: 6:62feedb1200e
408 415 tag: tip
409 416 user: test
410 417 date: Thu Jan 01 00:00:00 1970 +0000
411 418 summary: f
412 419
413 420
414 421 rollback should not work after a histedit
415 422 $ hg rollback
416 423 no rollback information available
417 424 [1]
418 425
419 426 $ cd ..
420 427 $ hg clone -qr0 r r0
421 428 $ cd r0
422 429 $ hg phase -fdr0
423 430 $ hg histedit --commands - 0 2>&1 << EOF
424 431 > edit cb9a9f314b8b a > $EDITED
425 432 > EOF
426 433 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
427 434 adding a
428 435 Make changes as needed, you may commit or record as needed now.
429 436 When you are finished, run hg histedit --continue to resume.
430 437 [1]
431 438 $ HGEDITOR=true hg histedit --continue
432 439 saved backup bundle to $TESTTMP/r0/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob)
433 440
434 441 $ hg log -G
435 442 @ changeset: 0:0efcea34f18a
436 443 tag: tip
437 444 user: test
438 445 date: Thu Jan 01 00:00:00 1970 +0000
439 446 summary: a
440 447
441 448 $ echo foo >> b
442 449 $ hg addr
443 450 adding b
444 451 $ hg ci -m 'add b'
445 452 $ echo foo >> a
446 453 $ hg ci -m 'extend a'
447 454 $ hg phase --public 1
448 455 Attempting to fold a change into a public change should not work:
449 456 $ cat > ../edit.sh <<EOF
450 457 > cat "\$1" | sed s/pick/fold/ > tmp
451 458 > mv tmp "\$1"
452 459 > EOF
453 460 $ HGEDITOR="sh ../edit.sh" hg histedit 2
454 461 warning: histedit rules saved to: .hg/histedit-last-edit.txt
455 462 abort: cannot fold into public change 18aa70c8ad22
456 463 [255]
457 464 $ cat .hg/histedit-last-edit.txt
458 465 fold 0012be4a27ea 2 extend a
459 466
460 467 # Edit history between 0012be4a27ea and 0012be4a27ea
461 468 #
462 469 # Commits are listed from least to most recent
463 470 #
464 471 # Commands:
465 472 # p, fold = use commit
466 473 # e, edit = use commit, but stop for amending
467 474 # f, fold = use commit, but combine it with the one above
468 475 # r, roll = like fold, but discard this commit's description
469 476 # d, drop = remove commit from history
470 477 # m, mess = edit commit message without changing commit content
471 478 #
General Comments 0
You need to be logged in to leave comments. Login now