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