| 1 |
#testcases abortcommand abortflag |
| 2 |
#testcases continuecommand continueflag |
| 3 |
|
| 4 |
$ cat >> $HGRCPATH <<EOF |
| 5 |
> [extensions] |
| 6 |
> rebase= |
| 7 |
> |
| 8 |
> [phases] |
| 9 |
> publish=False |
| 10 |
> |
| 11 |
> [alias] |
| 12 |
> tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n" |
| 13 |
> EOF |
| 14 |
|
| 15 |
#if abortflag |
| 16 |
$ cat >> $HGRCPATH <<EOF |
| 17 |
> [alias] |
| 18 |
> abort = rebase --abort |
| 19 |
> EOF |
| 20 |
#endif |
| 21 |
|
| 22 |
#if continueflag |
| 23 |
$ cat >> $HGRCPATH <<EOF |
| 24 |
> [alias] |
| 25 |
> continue = rebase --continue |
| 26 |
> EOF |
| 27 |
#endif |
| 28 |
|
| 29 |
$ hg init a |
| 30 |
$ cd a |
| 31 |
|
| 32 |
$ touch .hg/rebasestate |
| 33 |
$ hg sum |
| 34 |
parent: -1:000000000000 tip (empty repository) |
| 35 |
branch: default |
| 36 |
commit: (clean) |
| 37 |
update: (current) |
| 38 |
abort: .hg/rebasestate is incomplete |
| 39 |
[255] |
| 40 |
$ rm .hg/rebasestate |
| 41 |
|
| 42 |
$ echo c1 > common |
| 43 |
$ hg add common |
| 44 |
$ hg ci -m C1 |
| 45 |
|
| 46 |
$ echo c2 >> common |
| 47 |
$ hg ci -m C2 |
| 48 |
|
| 49 |
$ echo c3 >> common |
| 50 |
$ hg ci -m C3 |
| 51 |
|
| 52 |
$ hg up -q -C 1 |
| 53 |
|
| 54 |
$ echo l1 >> extra |
| 55 |
$ hg add extra |
| 56 |
$ hg ci -m L1 |
| 57 |
created new head |
| 58 |
|
| 59 |
$ sed -e 's/c2/l2/' common > common.new |
| 60 |
$ mv common.new common |
| 61 |
$ hg ci -m L2 |
| 62 |
|
| 63 |
$ hg phase --force --secret 2 |
| 64 |
|
| 65 |
$ hg tglog |
| 66 |
@ 4:draft 'L2' |
| 67 |
| |
| 68 |
o 3:draft 'L1' |
| 69 |
| |
| 70 |
| o 2:secret 'C3' |
| 71 |
|/ |
| 72 |
o 1:draft 'C2' |
| 73 |
| |
| 74 |
o 0:draft 'C1' |
| 75 |
|
| 76 |
|
| 77 |
Conflicting rebase: |
| 78 |
|
| 79 |
$ hg rebase -s 3 -d 2 |
| 80 |
rebasing 3:3163e20567cc "L1" |
| 81 |
rebasing 4:46f0b057b5c0 tip "L2" |
| 82 |
merging common |
| 83 |
warning: conflicts while merging common! (edit, then use 'hg resolve --mark') |
| 84 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 85 |
[240] |
| 86 |
|
| 87 |
Insert unsupported advisory merge record: |
| 88 |
|
| 89 |
$ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -x |
| 90 |
$ hg debugmergestate |
| 91 |
local (dest): 3e046f2ecedb793b97ed32108086edd1a162f8bc |
| 92 |
other (source): 46f0b057b5c061d276b91491c22151f78698abd2 |
| 93 |
file: common (state "u") |
| 94 |
local path: common (hash 94c8c21d08740f5da9eaa38d1f175c592692f0d1, flags "") |
| 95 |
ancestor path: common (node de0a666fdd9c1a0b0698b90d85064d8bd34f74b6) |
| 96 |
other path: common (node 2f6411de53677f6f1048fef5bf888d67a342e0a5) |
| 97 |
extra: ancestorlinknode = 3163e20567cc93074fbb7a53c8b93312e59dbf2c |
| 98 |
extra: merged = yes |
| 99 |
$ hg resolve -l |
| 100 |
U common |
| 101 |
|
| 102 |
Insert unsupported mandatory merge record: |
| 103 |
|
| 104 |
$ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -X |
| 105 |
$ hg debugmergestate |
| 106 |
abort: unsupported merge state records: X |
| 107 |
(see https://mercurial-scm.org/wiki/MergeStateRecords for more information) |
| 108 |
[255] |
| 109 |
$ hg resolve -l |
| 110 |
abort: unsupported merge state records: X |
| 111 |
(see https://mercurial-scm.org/wiki/MergeStateRecords for more information) |
| 112 |
[255] |
| 113 |
$ hg resolve -ma |
| 114 |
abort: unsupported merge state records: X |
| 115 |
(see https://mercurial-scm.org/wiki/MergeStateRecords for more information) |
| 116 |
[255] |
| 117 |
|
| 118 |
Abort (should clear out unsupported merge state): |
| 119 |
|
| 120 |
#if abortcommand |
| 121 |
when in dry-run mode |
| 122 |
$ hg abort --dry-run |
| 123 |
rebase in progress, will be aborted |
| 124 |
#endif |
| 125 |
|
| 126 |
$ hg abort |
| 127 |
saved backup bundle to $TESTTMP/a/.hg/strip-backup/3e046f2ecedb-6beef7d5-backup.hg |
| 128 |
rebase aborted |
| 129 |
$ hg debugmergestate |
| 130 |
no merge state found |
| 131 |
|
| 132 |
$ hg tglog |
| 133 |
@ 4:draft 'L2' |
| 134 |
| |
| 135 |
o 3:draft 'L1' |
| 136 |
| |
| 137 |
| o 2:secret 'C3' |
| 138 |
|/ |
| 139 |
o 1:draft 'C2' |
| 140 |
| |
| 141 |
o 0:draft 'C1' |
| 142 |
|
| 143 |
Test safety for inconsistent rebase state, which may be created (and |
| 144 |
forgotten) by Mercurial earlier than 2.7. This emulates Mercurial |
| 145 |
earlier than 2.7 by renaming ".hg/rebasestate" temporarily. |
| 146 |
|
| 147 |
$ hg rebase -s 3 -d 2 |
| 148 |
rebasing 3:3163e20567cc "L1" |
| 149 |
rebasing 4:46f0b057b5c0 tip "L2" |
| 150 |
merging common |
| 151 |
warning: conflicts while merging common! (edit, then use 'hg resolve --mark') |
| 152 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 153 |
[240] |
| 154 |
|
| 155 |
$ mv .hg/rebasestate .hg/rebasestate.back |
| 156 |
$ hg update --quiet --clean 2 |
| 157 |
$ hg --config extensions.mq= strip --quiet "destination()" |
| 158 |
$ mv .hg/rebasestate.back .hg/rebasestate |
| 159 |
|
| 160 |
$ hg continue |
| 161 |
abort: cannot continue inconsistent rebase |
| 162 |
(use "hg rebase --abort" to clear broken state) |
| 163 |
[255] |
| 164 |
$ hg summary | grep '^rebase: ' |
| 165 |
rebase: (use "hg rebase --abort" to clear broken state) |
| 166 |
$ hg abort |
| 167 |
rebase aborted (no revision is removed, only broken state is cleared) |
| 168 |
|
| 169 |
$ cd .. |
| 170 |
|
| 171 |
|
| 172 |
Construct new repo: |
| 173 |
|
| 174 |
$ hg init b |
| 175 |
$ cd b |
| 176 |
|
| 177 |
$ echo a > a |
| 178 |
$ hg ci -Am A |
| 179 |
adding a |
| 180 |
|
| 181 |
$ echo b > b |
| 182 |
$ hg ci -Am B |
| 183 |
adding b |
| 184 |
|
| 185 |
$ echo c > c |
| 186 |
$ hg ci -Am C |
| 187 |
adding c |
| 188 |
|
| 189 |
$ hg up -q 0 |
| 190 |
|
| 191 |
$ echo b > b |
| 192 |
$ hg ci -Am 'B bis' |
| 193 |
adding b |
| 194 |
created new head |
| 195 |
|
| 196 |
$ echo c1 > c |
| 197 |
$ hg ci -Am C1 |
| 198 |
adding c |
| 199 |
|
| 200 |
$ hg phase --force --secret 1 |
| 201 |
$ hg phase --public 1 |
| 202 |
|
| 203 |
Rebase and abort without generating new changesets: |
| 204 |
|
| 205 |
$ hg tglog |
| 206 |
@ 4:draft 'C1' |
| 207 |
| |
| 208 |
o 3:draft 'B bis' |
| 209 |
| |
| 210 |
| o 2:secret 'C' |
| 211 |
| | |
| 212 |
| o 1:public 'B' |
| 213 |
|/ |
| 214 |
o 0:public 'A' |
| 215 |
|
| 216 |
$ hg rebase -b 4 -d 2 |
| 217 |
rebasing 3:a6484957d6b9 "B bis" |
| 218 |
note: not rebasing 3:a6484957d6b9 "B bis", its destination already has all its changes |
| 219 |
rebasing 4:145842775fec tip "C1" |
| 220 |
merging c |
| 221 |
warning: conflicts while merging c! (edit, then use 'hg resolve --mark') |
| 222 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 223 |
[240] |
| 224 |
|
| 225 |
$ hg tglog |
| 226 |
% 4:draft 'C1' |
| 227 |
| |
| 228 |
o 3:draft 'B bis' |
| 229 |
| |
| 230 |
| @ 2:secret 'C' |
| 231 |
| | |
| 232 |
| o 1:public 'B' |
| 233 |
|/ |
| 234 |
o 0:public 'A' |
| 235 |
|
| 236 |
$ hg rebase -a |
| 237 |
rebase aborted |
| 238 |
|
| 239 |
$ hg tglog |
| 240 |
@ 4:draft 'C1' |
| 241 |
| |
| 242 |
o 3:draft 'B bis' |
| 243 |
| |
| 244 |
| o 2:secret 'C' |
| 245 |
| | |
| 246 |
| o 1:public 'B' |
| 247 |
|/ |
| 248 |
o 0:public 'A' |
| 249 |
|
| 250 |
|
| 251 |
$ cd .. |
| 252 |
|
| 253 |
rebase abort should not leave working copy in a merge state if tip-1 is public |
| 254 |
(issue4082) |
| 255 |
|
| 256 |
$ hg init abortpublic |
| 257 |
$ cd abortpublic |
| 258 |
$ echo a > a && hg ci -Aqm a |
| 259 |
$ hg book master |
| 260 |
$ hg book foo |
| 261 |
$ echo b > b && hg ci -Aqm b |
| 262 |
$ hg up -q master |
| 263 |
$ echo c > c && hg ci -Aqm c |
| 264 |
$ hg phase -p -r . |
| 265 |
$ hg up -q foo |
| 266 |
$ echo C > c && hg ci -Aqm C |
| 267 |
$ hg log -G --template "{rev} {desc} {bookmarks}" |
| 268 |
@ 3 C foo |
| 269 |
| |
| 270 |
| o 2 c master |
| 271 |
| | |
| 272 |
o | 1 b |
| 273 |
|/ |
| 274 |
o 0 a |
| 275 |
|
| 276 |
|
| 277 |
$ hg rebase -d master -r foo |
| 278 |
rebasing 3:6c0f977a22d8 foo tip "C" |
| 279 |
merging c |
| 280 |
warning: conflicts while merging c! (edit, then use 'hg resolve --mark') |
| 281 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 282 |
[240] |
| 283 |
$ hg abort |
| 284 |
rebase aborted |
| 285 |
$ hg log -G --template "{rev} {desc} {bookmarks}" |
| 286 |
@ 3 C foo |
| 287 |
| |
| 288 |
| o 2 c master |
| 289 |
| | |
| 290 |
o | 1 b |
| 291 |
|/ |
| 292 |
o 0 a |
| 293 |
|
| 294 |
$ cd .. |
| 295 |
|
| 296 |
Make sure we don't clobber changes in the working directory when the |
| 297 |
user has somehow managed to update to a different revision (issue4009) |
| 298 |
|
| 299 |
$ hg init noupdate |
| 300 |
$ cd noupdate |
| 301 |
$ hg book @ |
| 302 |
$ echo original > a |
| 303 |
$ hg add a |
| 304 |
$ hg commit -m a |
| 305 |
$ echo x > b |
| 306 |
$ hg add b |
| 307 |
$ hg commit -m b1 |
| 308 |
$ hg up 0 |
| 309 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 310 |
(leaving bookmark @) |
| 311 |
$ hg book foo |
| 312 |
$ echo y > b |
| 313 |
$ hg add b |
| 314 |
$ hg commit -m b2 |
| 315 |
created new head |
| 316 |
|
| 317 |
$ hg rebase -d @ -b foo --tool=internal:fail |
| 318 |
rebasing 2:070cf4580bb5 foo tip "b2" |
| 319 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 320 |
[240] |
| 321 |
|
| 322 |
$ mv .hg/rebasestate ./ # so we're allowed to hg up like in mercurial <2.6.3 |
| 323 |
$ hg up -C 0 # user does other stuff in the repo |
| 324 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 325 |
|
| 326 |
$ mv rebasestate .hg/ # user upgrades to 2.7 |
| 327 |
|
| 328 |
$ echo new > a |
| 329 |
$ hg up 1 # user gets an error saying to run hg rebase --abort |
| 330 |
abort: rebase in progress |
| 331 |
(use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop') |
| 332 |
[20] |
| 333 |
|
| 334 |
$ cat a |
| 335 |
new |
| 336 |
$ hg abort |
| 337 |
rebase aborted |
| 338 |
$ cat a |
| 339 |
new |
| 340 |
|
| 341 |
$ cd .. |
| 342 |
|
| 343 |
test aborting an interrupted series (issue5084) |
| 344 |
$ hg init interrupted |
| 345 |
$ cd interrupted |
| 346 |
$ touch base |
| 347 |
$ hg add base |
| 348 |
$ hg commit -m base |
| 349 |
$ touch a |
| 350 |
$ hg add a |
| 351 |
$ hg commit -m a |
| 352 |
$ echo 1 > a |
| 353 |
$ hg commit -m 1 |
| 354 |
$ touch b |
| 355 |
$ hg add b |
| 356 |
$ hg commit -m b |
| 357 |
$ echo 2 >> a |
| 358 |
$ hg commit -m c |
| 359 |
$ touch d |
| 360 |
$ hg add d |
| 361 |
$ hg commit -m d |
| 362 |
$ hg co -q 1 |
| 363 |
$ hg rm a |
| 364 |
$ hg commit -m no-a |
| 365 |
created new head |
| 366 |
$ hg co 0 |
| 367 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 368 |
$ hg log -G --template "{rev} {desc} {bookmarks}" |
| 369 |
o 6 no-a |
| 370 |
| |
| 371 |
| o 5 d |
| 372 |
| | |
| 373 |
| o 4 c |
| 374 |
| | |
| 375 |
| o 3 b |
| 376 |
| | |
| 377 |
| o 2 1 |
| 378 |
|/ |
| 379 |
o 1 a |
| 380 |
| |
| 381 |
@ 0 base |
| 382 |
|
| 383 |
$ hg --config extensions.n=$TESTDIR/failfilemerge.py rebase -s 3 -d tip |
| 384 |
rebasing 3:3a71550954f1 "b" |
| 385 |
rebasing 4:e80b69427d80 "c" |
| 386 |
abort: ^C |
| 387 |
[255] |
| 388 |
|
| 389 |
New operations are blocked with the correct state message |
| 390 |
|
| 391 |
$ find .hg -name '*state' -prune | sort |
| 392 |
.hg/dirstate |
| 393 |
.hg/merge/state |
| 394 |
.hg/rebasestate |
| 395 |
.hg/updatestate |
| 396 |
|
| 397 |
$ hg rebase -s 3 -d tip |
| 398 |
abort: rebase in progress |
| 399 |
(use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop') |
| 400 |
[20] |
| 401 |
$ hg up . |
| 402 |
abort: rebase in progress |
| 403 |
(use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop') |
| 404 |
[20] |
| 405 |
$ hg up -C . |
| 406 |
abort: rebase in progress |
| 407 |
(use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop') |
| 408 |
[20] |
| 409 |
|
| 410 |
$ hg graft 3 |
| 411 |
abort: rebase in progress |
| 412 |
(use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop') |
| 413 |
[20] |
| 414 |
|
| 415 |
$ hg abort |
| 416 |
saved backup bundle to $TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg |
| 417 |
rebase aborted |
| 418 |
$ hg log -G --template "{rev} {desc} {bookmarks}" |
| 419 |
o 6 no-a |
| 420 |
| |
| 421 |
| o 5 d |
| 422 |
| | |
| 423 |
| o 4 c |
| 424 |
| | |
| 425 |
| o 3 b |
| 426 |
| | |
| 427 |
| o 2 1 |
| 428 |
|/ |
| 429 |
o 1 a |
| 430 |
| |
| 431 |
@ 0 base |
| 432 |
|
| 433 |
$ hg summary |
| 434 |
parent: 0:df4f53cec30a |
| 435 |
base |
| 436 |
branch: default |
| 437 |
commit: (clean) |
| 438 |
update: 6 new changesets (update) |
| 439 |
phases: 7 draft |
| 440 |
|
| 441 |
$ cd .. |
| 442 |
On the other hand, make sure we *do* clobber changes whenever we |
| 443 |
haven't somehow managed to update the repo to a different revision |
| 444 |
during a rebase (issue4661) |
| 445 |
|
| 446 |
$ hg ini yesupdate |
| 447 |
$ cd yesupdate |
| 448 |
$ echo "initial data" > foo.txt |
| 449 |
$ hg add |
| 450 |
adding foo.txt |
| 451 |
$ hg ci -m "initial checkin" |
| 452 |
$ echo "change 1" > foo.txt |
| 453 |
$ hg ci -m "change 1" |
| 454 |
$ hg up 0 |
| 455 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 456 |
$ echo "conflicting change 1" > foo.txt |
| 457 |
$ hg ci -m "conflicting 1" |
| 458 |
created new head |
| 459 |
$ echo "conflicting change 2" > foo.txt |
| 460 |
$ hg ci -m "conflicting 2" |
| 461 |
|
| 462 |
$ hg rebase -d 1 --tool 'internal:fail' |
| 463 |
rebasing 2:e4ea5cdc9789 "conflicting 1" |
| 464 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 465 |
[240] |
| 466 |
$ hg abort |
| 467 |
rebase aborted |
| 468 |
$ hg summary |
| 469 |
parent: 3:b16646383533 tip |
| 470 |
conflicting 2 |
| 471 |
branch: default |
| 472 |
commit: (clean) |
| 473 |
update: 1 new changesets, 2 branch heads (merge) |
| 474 |
phases: 4 draft |
| 475 |
$ cd .. |
| 476 |
|
| 477 |
test aborting a rebase succeeds after rebasing with skipped commits onto a |
| 478 |
public changeset (issue4896) |
| 479 |
|
| 480 |
$ hg init succeedonpublic |
| 481 |
$ cd succeedonpublic |
| 482 |
$ echo 'content' > root |
| 483 |
$ hg commit -A -m 'root' -q |
| 484 |
|
| 485 |
set up public branch |
| 486 |
$ echo 'content' > disappear |
| 487 |
$ hg commit -A -m 'disappear public' -q |
| 488 |
commit will cause merge conflict on rebase |
| 489 |
$ echo '' > root |
| 490 |
$ hg commit -m 'remove content public' -q |
| 491 |
$ hg phase --public |
| 492 |
|
| 493 |
setup the draft branch that will be rebased onto public commit |
| 494 |
$ hg up -r 0 -q |
| 495 |
$ echo 'content' > disappear |
| 496 |
commit will disappear |
| 497 |
$ hg commit -A -m 'disappear draft' -q |
| 498 |
$ echo 'addedcontADDEDentadded' > root |
| 499 |
commit will cause merge conflict on rebase |
| 500 |
$ hg commit -m 'add content draft' -q |
| 501 |
|
| 502 |
$ hg rebase -d 'public()' --tool :merge -q |
| 503 |
note: not rebasing 3:0682fd3dabf5 "disappear draft", its destination already has all its changes |
| 504 |
warning: conflicts while merging root! (edit, then use 'hg resolve --mark') |
| 505 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 506 |
[240] |
| 507 |
$ hg abort |
| 508 |
rebase aborted |
| 509 |
$ cd .. |
| 510 |
|