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