| 1 |
$ cat >> $HGRCPATH <<EOF |
| 2 |
> [extensions] |
| 3 |
> rebase= |
| 4 |
> |
| 5 |
> [phases] |
| 6 |
> publish=False |
| 7 |
> |
| 8 |
> [alias] |
| 9 |
> tglog = log -G --template "{rev}: {node|short} '{desc}' {branches}\n" |
| 10 |
> tglogp = log -G --template "{rev}: {node|short} {phase} '{desc}' {branches}\n" |
| 11 |
> EOF |
| 12 |
|
| 13 |
|
| 14 |
$ hg init a |
| 15 |
$ cd a |
| 16 |
|
| 17 |
$ echo A > A |
| 18 |
$ hg ci -Am A |
| 19 |
adding A |
| 20 |
|
| 21 |
$ echo B > B |
| 22 |
$ hg ci -Am B |
| 23 |
adding B |
| 24 |
|
| 25 |
$ echo C >> A |
| 26 |
$ hg ci -m C |
| 27 |
|
| 28 |
$ hg up -q -C 0 |
| 29 |
|
| 30 |
$ echo D >> A |
| 31 |
$ hg ci -m D |
| 32 |
created new head |
| 33 |
|
| 34 |
$ echo E > E |
| 35 |
$ hg ci -Am E |
| 36 |
adding E |
| 37 |
|
| 38 |
$ cd .. |
| 39 |
|
| 40 |
|
| 41 |
Changes during an interruption - continue: |
| 42 |
|
| 43 |
$ hg clone -q -u . a a1 |
| 44 |
$ cd a1 |
| 45 |
|
| 46 |
$ hg tglog |
| 47 |
@ 4: ae36e8e3dfd7 'E' |
| 48 |
| |
| 49 |
o 3: 46b37eabc604 'D' |
| 50 |
| |
| 51 |
| o 2: 965c486023db 'C' |
| 52 |
| | |
| 53 |
| o 1: 27547f69f254 'B' |
| 54 |
|/ |
| 55 |
o 0: 4a2df7238c3b 'A' |
| 56 |
|
| 57 |
Rebasing B onto E: |
| 58 |
|
| 59 |
$ hg rebase -s 1 -d 4 |
| 60 |
rebasing 1:27547f69f254 "B" |
| 61 |
rebasing 2:965c486023db "C" |
| 62 |
merging A |
| 63 |
warning: conflicts while merging A! (edit, then use 'hg resolve --mark') |
| 64 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 65 |
[240] |
| 66 |
|
| 67 |
Force a commit on C during the interruption: |
| 68 |
|
| 69 |
$ hg up -q -C 2 --config 'extensions.rebase=!' |
| 70 |
|
| 71 |
$ echo 'Extra' > Extra |
| 72 |
$ hg add Extra |
| 73 |
$ hg ci -m 'Extra' --config 'extensions.rebase=!' |
| 74 |
|
| 75 |
Force this commit onto secret phase |
| 76 |
|
| 77 |
$ hg phase --force --secret 6 |
| 78 |
|
| 79 |
$ hg tglogp |
| 80 |
@ 6: deb5d2f93d8b secret 'Extra' |
| 81 |
| |
| 82 |
| o 5: 45396c49d53b draft 'B' |
| 83 |
| | |
| 84 |
| o 4: ae36e8e3dfd7 draft 'E' |
| 85 |
| | |
| 86 |
| o 3: 46b37eabc604 draft 'D' |
| 87 |
| | |
| 88 |
o | 2: 965c486023db draft 'C' |
| 89 |
| | |
| 90 |
o | 1: 27547f69f254 draft 'B' |
| 91 |
|/ |
| 92 |
o 0: 4a2df7238c3b draft 'A' |
| 93 |
|
| 94 |
Resume the rebasing: |
| 95 |
|
| 96 |
$ hg rebase --continue |
| 97 |
already rebased 1:27547f69f254 "B" as 45396c49d53b |
| 98 |
rebasing 2:965c486023db "C" |
| 99 |
merging A |
| 100 |
warning: conflicts while merging A! (edit, then use 'hg resolve --mark') |
| 101 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 102 |
[240] |
| 103 |
|
| 104 |
Solve the conflict and go on: |
| 105 |
|
| 106 |
$ echo 'conflict solved' > A |
| 107 |
$ rm A.orig |
| 108 |
$ hg resolve -m A |
| 109 |
(no more unresolved files) |
| 110 |
continue: hg rebase --continue |
| 111 |
|
| 112 |
$ hg rebase --continue |
| 113 |
already rebased 1:27547f69f254 "B" as 45396c49d53b |
| 114 |
rebasing 2:965c486023db "C" |
| 115 |
warning: orphaned descendants detected, not stripping 27547f69f254, 965c486023db |
| 116 |
|
| 117 |
$ hg tglogp |
| 118 |
o 7: d2d25e26288e draft 'C' |
| 119 |
| |
| 120 |
| o 6: deb5d2f93d8b secret 'Extra' |
| 121 |
| | |
| 122 |
o | 5: 45396c49d53b draft 'B' |
| 123 |
| | |
| 124 |
@ | 4: ae36e8e3dfd7 draft 'E' |
| 125 |
| | |
| 126 |
o | 3: 46b37eabc604 draft 'D' |
| 127 |
| | |
| 128 |
| o 2: 965c486023db draft 'C' |
| 129 |
| | |
| 130 |
| o 1: 27547f69f254 draft 'B' |
| 131 |
|/ |
| 132 |
o 0: 4a2df7238c3b draft 'A' |
| 133 |
|
| 134 |
$ cd .. |
| 135 |
|
| 136 |
|
| 137 |
Changes during an interruption - abort: |
| 138 |
|
| 139 |
$ hg clone -q -u . a a2 |
| 140 |
$ cd a2 |
| 141 |
|
| 142 |
$ hg tglog |
| 143 |
@ 4: ae36e8e3dfd7 'E' |
| 144 |
| |
| 145 |
o 3: 46b37eabc604 'D' |
| 146 |
| |
| 147 |
| o 2: 965c486023db 'C' |
| 148 |
| | |
| 149 |
| o 1: 27547f69f254 'B' |
| 150 |
|/ |
| 151 |
o 0: 4a2df7238c3b 'A' |
| 152 |
|
| 153 |
Rebasing B onto E: |
| 154 |
|
| 155 |
$ hg rebase -s 1 -d 4 |
| 156 |
rebasing 1:27547f69f254 "B" |
| 157 |
rebasing 2:965c486023db "C" |
| 158 |
merging A |
| 159 |
warning: conflicts while merging A! (edit, then use 'hg resolve --mark') |
| 160 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 161 |
[240] |
| 162 |
|
| 163 |
Force a commit on B' during the interruption: |
| 164 |
|
| 165 |
$ hg up -q -C 5 --config 'extensions.rebase=!' |
| 166 |
|
| 167 |
$ echo 'Extra' > Extra |
| 168 |
$ hg add Extra |
| 169 |
$ hg ci -m 'Extra' --config 'extensions.rebase=!' |
| 170 |
|
| 171 |
$ hg tglog |
| 172 |
@ 6: 402ee3642b59 'Extra' |
| 173 |
| |
| 174 |
o 5: 45396c49d53b 'B' |
| 175 |
| |
| 176 |
o 4: ae36e8e3dfd7 'E' |
| 177 |
| |
| 178 |
o 3: 46b37eabc604 'D' |
| 179 |
| |
| 180 |
| o 2: 965c486023db 'C' |
| 181 |
| | |
| 182 |
| o 1: 27547f69f254 'B' |
| 183 |
|/ |
| 184 |
o 0: 4a2df7238c3b 'A' |
| 185 |
|
| 186 |
Abort the rebasing: |
| 187 |
|
| 188 |
$ hg rebase --abort |
| 189 |
warning: new changesets detected on destination branch, can't strip |
| 190 |
rebase aborted |
| 191 |
|
| 192 |
$ hg tglog |
| 193 |
@ 6: 402ee3642b59 'Extra' |
| 194 |
| |
| 195 |
o 5: 45396c49d53b 'B' |
| 196 |
| |
| 197 |
o 4: ae36e8e3dfd7 'E' |
| 198 |
| |
| 199 |
o 3: 46b37eabc604 'D' |
| 200 |
| |
| 201 |
| o 2: 965c486023db 'C' |
| 202 |
| | |
| 203 |
| o 1: 27547f69f254 'B' |
| 204 |
|/ |
| 205 |
o 0: 4a2df7238c3b 'A' |
| 206 |
|
| 207 |
$ cd .. |
| 208 |
|
| 209 |
Changes during an interruption - abort (again): |
| 210 |
|
| 211 |
$ hg clone -q -u . a a3 |
| 212 |
$ cd a3 |
| 213 |
|
| 214 |
$ hg tglogp |
| 215 |
@ 4: ae36e8e3dfd7 draft 'E' |
| 216 |
| |
| 217 |
o 3: 46b37eabc604 draft 'D' |
| 218 |
| |
| 219 |
| o 2: 965c486023db draft 'C' |
| 220 |
| | |
| 221 |
| o 1: 27547f69f254 draft 'B' |
| 222 |
|/ |
| 223 |
o 0: 4a2df7238c3b draft 'A' |
| 224 |
|
| 225 |
Rebasing B onto E: |
| 226 |
|
| 227 |
$ hg rebase -s 1 -d 4 |
| 228 |
rebasing 1:27547f69f254 "B" |
| 229 |
rebasing 2:965c486023db "C" |
| 230 |
merging A |
| 231 |
warning: conflicts while merging A! (edit, then use 'hg resolve --mark') |
| 232 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 233 |
[240] |
| 234 |
|
| 235 |
Change phase on B and B' |
| 236 |
|
| 237 |
$ hg up -q -C 5 --config 'extensions.rebase=!' |
| 238 |
$ hg phase --public 1 |
| 239 |
$ hg phase --public 5 |
| 240 |
$ hg phase --secret -f 2 |
| 241 |
|
| 242 |
$ hg tglogp |
| 243 |
@ 5: 45396c49d53b public 'B' |
| 244 |
| |
| 245 |
o 4: ae36e8e3dfd7 public 'E' |
| 246 |
| |
| 247 |
o 3: 46b37eabc604 public 'D' |
| 248 |
| |
| 249 |
| o 2: 965c486023db secret 'C' |
| 250 |
| | |
| 251 |
| o 1: 27547f69f254 public 'B' |
| 252 |
|/ |
| 253 |
o 0: 4a2df7238c3b public 'A' |
| 254 |
|
| 255 |
Abort the rebasing: |
| 256 |
|
| 257 |
$ hg rebase --abort |
| 258 |
warning: can't clean up public changesets 45396c49d53b |
| 259 |
rebase aborted |
| 260 |
|
| 261 |
$ hg tglogp |
| 262 |
@ 5: 45396c49d53b public 'B' |
| 263 |
| |
| 264 |
o 4: ae36e8e3dfd7 public 'E' |
| 265 |
| |
| 266 |
o 3: 46b37eabc604 public 'D' |
| 267 |
| |
| 268 |
| o 2: 965c486023db secret 'C' |
| 269 |
| | |
| 270 |
| o 1: 27547f69f254 public 'B' |
| 271 |
|/ |
| 272 |
o 0: 4a2df7238c3b public 'A' |
| 273 |
|
| 274 |
Test rebase interrupted by hooks |
| 275 |
|
| 276 |
$ hg up 2 |
| 277 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 278 |
$ echo F > F |
| 279 |
$ hg add F |
| 280 |
$ hg ci -m F |
| 281 |
|
| 282 |
$ cd .. |
| 283 |
|
| 284 |
Continue rebase after upgrading from an hg version before 9c9cfecd4600: |
| 285 |
|
| 286 |
$ hg clone -q -u . a a4 |
| 287 |
$ cd a4 |
| 288 |
|
| 289 |
$ hg tglog |
| 290 |
@ 4: ae36e8e3dfd7 'E' |
| 291 |
| |
| 292 |
o 3: 46b37eabc604 'D' |
| 293 |
| |
| 294 |
| o 2: 965c486023db 'C' |
| 295 |
| | |
| 296 |
| o 1: 27547f69f254 'B' |
| 297 |
|/ |
| 298 |
o 0: 4a2df7238c3b 'A' |
| 299 |
|
| 300 |
$ hg rebase -s 1 -d 4 |
| 301 |
rebasing 1:27547f69f254 "B" |
| 302 |
rebasing 2:965c486023db "C" |
| 303 |
merging A |
| 304 |
warning: conflicts while merging A! (edit, then use 'hg resolve --mark') |
| 305 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 306 |
[240] |
| 307 |
$ hg tglog |
| 308 |
@ 5: 45396c49d53b 'B' |
| 309 |
| |
| 310 |
o 4: ae36e8e3dfd7 'E' |
| 311 |
| |
| 312 |
o 3: 46b37eabc604 'D' |
| 313 |
| |
| 314 |
| % 2: 965c486023db 'C' |
| 315 |
| | |
| 316 |
| o 1: 27547f69f254 'B' |
| 317 |
|/ |
| 318 |
o 0: 4a2df7238c3b 'A' |
| 319 |
|
| 320 |
Simulate having run the above with an older hg version by manually setting |
| 321 |
two dirstate parents. We should not get a merge commit when we continue. |
| 322 |
$ hg debugsetparents 5 2 |
| 323 |
$ echo 'conflict solved' > A |
| 324 |
$ hg resolve -m A |
| 325 |
(no more unresolved files) |
| 326 |
continue: hg rebase --continue |
| 327 |
$ hg rebase --continue |
| 328 |
already rebased 1:27547f69f254 "B" as 45396c49d53b |
| 329 |
rebasing 2:965c486023db "C" |
| 330 |
saved backup bundle to $TESTTMP/a4/.hg/strip-backup/27547f69f254-359abdd7-rebase.hg |
| 331 |
$ hg tglog |
| 332 |
o 4: d2d25e26288e 'C' |
| 333 |
| |
| 334 |
o 3: 45396c49d53b 'B' |
| 335 |
| |
| 336 |
@ 2: ae36e8e3dfd7 'E' |
| 337 |
| |
| 338 |
o 1: 46b37eabc604 'D' |
| 339 |
| |
| 340 |
o 0: 4a2df7238c3b 'A' |
| 341 |
|
| 342 |
$ cd .. |
| 343 |
|
| 344 |
(precommit version) |
| 345 |
|
| 346 |
$ cp -R a3 hook-precommit |
| 347 |
$ cd hook-precommit |
| 348 |
$ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.precommit=hg status | grep "M A"' |
| 349 |
rebasing 2:965c486023db "C" |
| 350 |
M A |
| 351 |
rebasing 6:a0b2430ebfb8 tip "F" |
| 352 |
abort: precommit hook exited with status 1 |
| 353 |
[40] |
| 354 |
$ hg tglogp |
| 355 |
@ 7: 401ccec5e39f secret 'C' |
| 356 |
| |
| 357 |
| o 6: a0b2430ebfb8 secret 'F' |
| 358 |
| | |
| 359 |
o | 5: 45396c49d53b public 'B' |
| 360 |
| | |
| 361 |
o | 4: ae36e8e3dfd7 public 'E' |
| 362 |
| | |
| 363 |
o | 3: 46b37eabc604 public 'D' |
| 364 |
| | |
| 365 |
| o 2: 965c486023db secret 'C' |
| 366 |
| | |
| 367 |
| o 1: 27547f69f254 public 'B' |
| 368 |
|/ |
| 369 |
o 0: 4a2df7238c3b public 'A' |
| 370 |
|
| 371 |
$ hg rebase --continue |
| 372 |
already rebased 2:965c486023db "C" as 401ccec5e39f |
| 373 |
rebasing 6:a0b2430ebfb8 "F" |
| 374 |
saved backup bundle to $TESTTMP/hook-precommit/.hg/strip-backup/965c486023db-aa6250e7-rebase.hg |
| 375 |
$ hg tglogp |
| 376 |
@ 6: 6e92a149ac6b secret 'F' |
| 377 |
| |
| 378 |
o 5: 401ccec5e39f secret 'C' |
| 379 |
| |
| 380 |
o 4: 45396c49d53b public 'B' |
| 381 |
| |
| 382 |
o 3: ae36e8e3dfd7 public 'E' |
| 383 |
| |
| 384 |
o 2: 46b37eabc604 public 'D' |
| 385 |
| |
| 386 |
| o 1: 27547f69f254 public 'B' |
| 387 |
|/ |
| 388 |
o 0: 4a2df7238c3b public 'A' |
| 389 |
|
| 390 |
$ cd .. |
| 391 |
|
| 392 |
(pretxncommit version) |
| 393 |
|
| 394 |
$ cp -R a3 hook-pretxncommit |
| 395 |
$ cd hook-pretxncommit |
| 396 |
$ hg rebase --source 2 --dest 5 --tool internal:other \ |
| 397 |
> --config 'hooks.tonative.pretxncommit=True' --config 'hooks.pretxncommit=hg log -r $HG_NODE | grep "summary: C"' |
| 398 |
rebasing 2:965c486023db "C" |
| 399 |
summary: C |
| 400 |
rebasing 6:a0b2430ebfb8 tip "F" |
| 401 |
transaction abort! |
| 402 |
rollback completed |
| 403 |
abort: pretxncommit hook exited with status 1 |
| 404 |
[40] |
| 405 |
$ hg tglogp |
| 406 |
@ 7: 401ccec5e39f secret 'C' |
| 407 |
| |
| 408 |
| o 6: a0b2430ebfb8 secret 'F' |
| 409 |
| | |
| 410 |
o | 5: 45396c49d53b public 'B' |
| 411 |
| | |
| 412 |
o | 4: ae36e8e3dfd7 public 'E' |
| 413 |
| | |
| 414 |
o | 3: 46b37eabc604 public 'D' |
| 415 |
| | |
| 416 |
| o 2: 965c486023db secret 'C' |
| 417 |
| | |
| 418 |
| o 1: 27547f69f254 public 'B' |
| 419 |
|/ |
| 420 |
o 0: 4a2df7238c3b public 'A' |
| 421 |
|
| 422 |
$ hg rebase --continue |
| 423 |
already rebased 2:965c486023db "C" as 401ccec5e39f |
| 424 |
rebasing 6:a0b2430ebfb8 "F" |
| 425 |
saved backup bundle to $TESTTMP/hook-pretxncommit/.hg/strip-backup/965c486023db-aa6250e7-rebase.hg |
| 426 |
$ hg tglogp |
| 427 |
@ 6: 6e92a149ac6b secret 'F' |
| 428 |
| |
| 429 |
o 5: 401ccec5e39f secret 'C' |
| 430 |
| |
| 431 |
o 4: 45396c49d53b public 'B' |
| 432 |
| |
| 433 |
o 3: ae36e8e3dfd7 public 'E' |
| 434 |
| |
| 435 |
o 2: 46b37eabc604 public 'D' |
| 436 |
| |
| 437 |
| o 1: 27547f69f254 public 'B' |
| 438 |
|/ |
| 439 |
o 0: 4a2df7238c3b public 'A' |
| 440 |
|
| 441 |
$ cd .. |
| 442 |
|
| 443 |
(pretxnclose version) |
| 444 |
|
| 445 |
$ cp -R a3 hook-pretxnclose |
| 446 |
$ cd hook-pretxnclose |
| 447 |
$ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.pretxnclose=hg log -r tip | grep "summary: C"' |
| 448 |
rebasing 2:965c486023db "C" |
| 449 |
summary: C |
| 450 |
rebasing 6:a0b2430ebfb8 tip "F" |
| 451 |
transaction abort! |
| 452 |
rollback completed |
| 453 |
abort: pretxnclose hook exited with status 1 |
| 454 |
[40] |
| 455 |
$ hg tglogp |
| 456 |
@ 7: 401ccec5e39f secret 'C' |
| 457 |
| |
| 458 |
| o 6: a0b2430ebfb8 secret 'F' |
| 459 |
| | |
| 460 |
o | 5: 45396c49d53b public 'B' |
| 461 |
| | |
| 462 |
o | 4: ae36e8e3dfd7 public 'E' |
| 463 |
| | |
| 464 |
o | 3: 46b37eabc604 public 'D' |
| 465 |
| | |
| 466 |
| o 2: 965c486023db secret 'C' |
| 467 |
| | |
| 468 |
| o 1: 27547f69f254 public 'B' |
| 469 |
|/ |
| 470 |
o 0: 4a2df7238c3b public 'A' |
| 471 |
|
| 472 |
$ hg rebase --continue |
| 473 |
already rebased 2:965c486023db "C" as 401ccec5e39f |
| 474 |
rebasing 6:a0b2430ebfb8 "F" |
| 475 |
saved backup bundle to $TESTTMP/hook-pretxnclose/.hg/strip-backup/965c486023db-aa6250e7-rebase.hg |
| 476 |
$ hg tglogp |
| 477 |
@ 6: 6e92a149ac6b secret 'F' |
| 478 |
| |
| 479 |
o 5: 401ccec5e39f secret 'C' |
| 480 |
| |
| 481 |
o 4: 45396c49d53b public 'B' |
| 482 |
| |
| 483 |
o 3: ae36e8e3dfd7 public 'E' |
| 484 |
| |
| 485 |
o 2: 46b37eabc604 public 'D' |
| 486 |
| |
| 487 |
| o 1: 27547f69f254 public 'B' |
| 488 |
|/ |
| 489 |
o 0: 4a2df7238c3b public 'A' |
| 490 |
|
| 491 |
$ cd .. |
| 492 |
|
| 493 |
Make sure merge state is cleaned up after a no-op rebase merge (issue5494) |
| 494 |
$ hg init repo |
| 495 |
$ cd repo |
| 496 |
$ echo a > a |
| 497 |
$ hg commit -qAm base |
| 498 |
$ echo b >> a |
| 499 |
$ hg commit -qm b |
| 500 |
$ hg up '.^' |
| 501 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 502 |
$ echo c >> a |
| 503 |
$ hg commit -qm c |
| 504 |
$ hg rebase -s 1 -d 2 --noninteractive |
| 505 |
rebasing 1:fdaca8533b86 "b" |
| 506 |
merging a |
| 507 |
warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
| 508 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 509 |
[240] |
| 510 |
$ echo a > a |
| 511 |
$ echo c >> a |
| 512 |
$ hg resolve --mark a |
| 513 |
(no more unresolved files) |
| 514 |
continue: hg rebase --continue |
| 515 |
$ hg rebase --continue |
| 516 |
rebasing 1:fdaca8533b86 "b" |
| 517 |
note: not rebasing 1:fdaca8533b86 "b", its destination already has all its changes |
| 518 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/fdaca8533b86-7fd70513-rebase.hg |
| 519 |
$ hg resolve --list |
| 520 |
$ test -d .hg/merge |
| 521 |
[1] |
| 522 |
Now try again with --collapse |
| 523 |
$ hg unbundle -q .hg/strip-backup/fdaca8533b86-7fd70513-rebase.hg |
| 524 |
$ hg rebase -s 2 -d 1 --noninteractive --collapse |
| 525 |
rebasing 2:fdaca8533b86 tip "b" |
| 526 |
merging a |
| 527 |
warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
| 528 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 529 |
[240] |
| 530 |
$ echo a > a |
| 531 |
$ echo c >> a |
| 532 |
$ hg resolve --mark a |
| 533 |
(no more unresolved files) |
| 534 |
continue: hg rebase --continue |
| 535 |
$ hg rebase --continue |
| 536 |
rebasing 2:fdaca8533b86 tip "b" |
| 537 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/fdaca8533b86-7fd70513-rebase.hg |
| 538 |
$ hg resolve --list |
| 539 |
$ test -d .hg/merge |
| 540 |
[1] |