| 1 |
Require a destination |
| 2 |
$ cat >> $HGRCPATH <<EOF |
| 3 |
> [extensions] |
| 4 |
> rebase = |
| 5 |
> [commands] |
| 6 |
> rebase.requiredest = True |
| 7 |
> EOF |
| 8 |
$ hg init repo |
| 9 |
$ cd repo |
| 10 |
$ echo a >> a |
| 11 |
$ hg commit -qAm aa |
| 12 |
$ echo b >> b |
| 13 |
$ hg commit -qAm bb |
| 14 |
$ hg up ".^" |
| 15 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 16 |
$ echo c >> c |
| 17 |
$ hg commit -qAm cc |
| 18 |
$ hg rebase |
| 19 |
abort: you must specify a destination |
| 20 |
(use: hg rebase -d REV) |
| 21 |
[10] |
| 22 |
$ hg rebase -d 1 |
| 23 |
rebasing 2:5db65b93a12b tip "cc" |
| 24 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/5db65b93a12b-4fb789ec-rebase.hg |
| 25 |
$ hg rebase -d 0 -r . -q |
| 26 |
$ HGPLAIN=1 hg rebase |
| 27 |
rebasing 2:889b0bc6a730 tip "cc" |
| 28 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/889b0bc6a730-41ec4f81-rebase.hg |
| 29 |
$ hg rebase -d 0 -r . -q |
| 30 |
$ hg --config commands.rebase.requiredest=False rebase |
| 31 |
rebasing 2:279de9495438 tip "cc" |
| 32 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/279de9495438-ab0a5128-rebase.hg |
| 33 |
|
| 34 |
Requiring dest should not break continue or other rebase options |
| 35 |
$ hg up 1 -q |
| 36 |
$ echo d >> c |
| 37 |
$ hg commit -qAm dc |
| 38 |
$ hg log -G -T '{rev} {desc}' |
| 39 |
@ 3 dc |
| 40 |
| |
| 41 |
| o 2 cc |
| 42 |
|/ |
| 43 |
o 1 bb |
| 44 |
| |
| 45 |
o 0 aa |
| 46 |
|
| 47 |
$ hg rebase -d 2 |
| 48 |
rebasing 3:0537f6b50def tip "dc" |
| 49 |
merging c |
| 50 |
warning: conflicts while merging c! (edit, then use 'hg resolve --mark') |
| 51 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 52 |
[240] |
| 53 |
$ echo d > c |
| 54 |
$ hg resolve --mark --all |
| 55 |
(no more unresolved files) |
| 56 |
continue: hg rebase --continue |
| 57 |
$ hg rebase --continue |
| 58 |
rebasing 3:0537f6b50def tip "dc" |
| 59 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/0537f6b50def-be4c7386-rebase.hg |
| 60 |
|
| 61 |
$ cd .. |
| 62 |
|
| 63 |
Check rebase.requiredest interaction with pull --rebase |
| 64 |
$ hg clone repo clone |
| 65 |
updating to branch default |
| 66 |
3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 67 |
$ cd repo |
| 68 |
$ echo e > e |
| 69 |
$ hg commit -qAm ee |
| 70 |
$ cd .. |
| 71 |
$ cd clone |
| 72 |
$ echo f > f |
| 73 |
$ hg commit -qAm ff |
| 74 |
$ hg pull --rebase |
| 75 |
abort: rebase destination required by configuration |
| 76 |
(use hg pull followed by hg rebase -d DEST) |
| 77 |
[10] |
| 78 |
|
| 79 |
Setup rebase with multiple destinations |
| 80 |
|
| 81 |
$ cd $TESTTMP |
| 82 |
|
| 83 |
$ cat >> $TESTTMP/maprevset.py <<EOF |
| 84 |
> from mercurial import registrar, revset, revsetlang, smartset |
| 85 |
> revsetpredicate = registrar.revsetpredicate() |
| 86 |
> cache = {} |
| 87 |
> @revsetpredicate(b'map') |
| 88 |
> def map(repo, subset, x): |
| 89 |
> """(set, mapping)""" |
| 90 |
> setarg, maparg = revsetlang.getargs(x, 2, 2, b'') |
| 91 |
> rset = revset.getset(repo, smartset.fullreposet(repo), setarg) |
| 92 |
> mapstr = revsetlang.getstring(maparg, b'') |
| 93 |
> map = dict(a.split(b':') for a in mapstr.split(b',')) |
| 94 |
> rev = rset.first() |
| 95 |
> desc = repo[rev].description() |
| 96 |
> newdesc = map.get(desc) |
| 97 |
> if newdesc == b'null': |
| 98 |
> revs = [-1] |
| 99 |
> else: |
| 100 |
> query = revsetlang.formatspec(b'desc(%s)', newdesc) |
| 101 |
> revs = repo.revs(query) |
| 102 |
> return smartset.baseset(revs) |
| 103 |
> EOF |
| 104 |
|
| 105 |
$ cat >> $HGRCPATH <<EOF |
| 106 |
> [ui] |
| 107 |
> allowemptycommit=1 |
| 108 |
> [extensions] |
| 109 |
> drawdag=$TESTDIR/drawdag.py |
| 110 |
> [phases] |
| 111 |
> publish=False |
| 112 |
> [alias] |
| 113 |
> tglog = log -G --template "{rev}: {node|short} {desc} {instabilities}" -r 'sort(all(), topo)' |
| 114 |
> [extensions] |
| 115 |
> maprevset=$TESTTMP/maprevset.py |
| 116 |
> [experimental] |
| 117 |
> evolution=true |
| 118 |
> EOF |
| 119 |
|
| 120 |
$ rebasewithdag() { |
| 121 |
> N=`"$PYTHON" -c "print($N+1)"` |
| 122 |
> hg init repo$N && cd repo$N |
| 123 |
> hg debugdrawdag |
| 124 |
> hg rebase "$@" > _rebasetmp |
| 125 |
> r=$? |
| 126 |
> grep -v 'saved backup bundle' _rebasetmp |
| 127 |
> [ $r -eq 0 ] && rm -f .hg/localtags && hg tglog |
| 128 |
> cd .. |
| 129 |
> return $r |
| 130 |
> } |
| 131 |
|
| 132 |
Destination resolves to an empty set: |
| 133 |
|
| 134 |
$ rebasewithdag -s B -d 'SRC - SRC' <<'EOS' |
| 135 |
> C |
| 136 |
> | |
| 137 |
> B |
| 138 |
> | |
| 139 |
> A |
| 140 |
> EOS |
| 141 |
nothing to rebase - empty destination |
| 142 |
[1] |
| 143 |
|
| 144 |
Multiple destinations and --collapse are not compatible: |
| 145 |
|
| 146 |
$ rebasewithdag -s C+E -d 'SRC^^' --collapse <<'EOS' |
| 147 |
> C F |
| 148 |
> | | |
| 149 |
> B E |
| 150 |
> | | |
| 151 |
> A D |
| 152 |
> EOS |
| 153 |
abort: --collapse does not work with multiple destinations |
| 154 |
[10] |
| 155 |
|
| 156 |
Multiple destinations cannot be used with --base: |
| 157 |
|
| 158 |
$ rebasewithdag -b B -b E -d 'SRC^^' --collapse <<'EOS' |
| 159 |
> B E |
| 160 |
> | | |
| 161 |
> A D |
| 162 |
> EOS |
| 163 |
abort: unknown revision 'SRC' |
| 164 |
[10] |
| 165 |
|
| 166 |
Rebase to null should work: |
| 167 |
|
| 168 |
$ rebasewithdag -r A+C+D -d 'null' <<'EOS' |
| 169 |
> C D |
| 170 |
> | | |
| 171 |
> A B |
| 172 |
> EOS |
| 173 |
already rebased 0:426bada5c675 A "A" |
| 174 |
already rebased 2:dc0947a82db8 C "C" |
| 175 |
rebasing 3:004dc1679908 D tip "D" |
| 176 |
o 4: d8d8601abd5e D |
| 177 |
|
| 178 |
o 2: dc0947a82db8 C |
| 179 |
| |
| 180 |
| o 1: fc2b737bb2e5 B |
| 181 |
| |
| 182 |
o 0: 426bada5c675 A |
| 183 |
|
| 184 |
Destination resolves to multiple changesets: |
| 185 |
|
| 186 |
$ rebasewithdag -s B -d 'ALLSRC+SRC' <<'EOS' |
| 187 |
> C |
| 188 |
> | |
| 189 |
> B |
| 190 |
> | |
| 191 |
> Z |
| 192 |
> EOS |
| 193 |
abort: rebase destination for f0a671a46792 is not unique |
| 194 |
[10] |
| 195 |
|
| 196 |
Destination is an ancestor of source: |
| 197 |
|
| 198 |
$ rebasewithdag -s B -d 'SRC' <<'EOS' |
| 199 |
> C |
| 200 |
> | |
| 201 |
> B |
| 202 |
> | |
| 203 |
> Z |
| 204 |
> EOS |
| 205 |
abort: source and destination form a cycle |
| 206 |
[10] |
| 207 |
|
| 208 |
BUG: cycles aren't flagged correctly when --dry-run is set: |
| 209 |
$ rebasewithdag -s B -d 'SRC' --dry-run <<'EOS' |
| 210 |
> C |
| 211 |
> | |
| 212 |
> B |
| 213 |
> | |
| 214 |
> Z |
| 215 |
> EOS |
| 216 |
abort: source and destination form a cycle |
| 217 |
starting dry-run rebase; repository will not be changed |
| 218 |
[10] |
| 219 |
|
| 220 |
Switch roots: |
| 221 |
|
| 222 |
$ rebasewithdag -s 'all() - roots(all())' -d 'roots(all()) - ::SRC' <<'EOS' |
| 223 |
> C F |
| 224 |
> | | |
| 225 |
> B E |
| 226 |
> | | |
| 227 |
> A D |
| 228 |
> EOS |
| 229 |
rebasing 2:112478962961 B "B" |
| 230 |
rebasing 4:26805aba1e60 C "C" |
| 231 |
rebasing 3:cd488e83d208 E "E" |
| 232 |
rebasing 5:0069ba24938a F tip "F" |
| 233 |
o 9: d150ff263fc8 F |
| 234 |
| |
| 235 |
o 8: 66f30a1a2eab E |
| 236 |
| |
| 237 |
| o 7: 93db94ffae0e C |
| 238 |
| | |
| 239 |
| o 6: d0071c3b0c88 B |
| 240 |
| | |
| 241 |
| o 1: 058c1e1fb10a D |
| 242 |
| |
| 243 |
o 0: 426bada5c675 A |
| 244 |
|
| 245 |
Different destinations for merge changesets with a same root: |
| 246 |
|
| 247 |
$ rebasewithdag -s B -d '((parents(SRC)-B-A)::) - (::ALLSRC)' <<'EOS' |
| 248 |
> C G |
| 249 |
> |\| |
| 250 |
> | F |
| 251 |
> | |
| 252 |
> B E |
| 253 |
> |\| |
| 254 |
> A D |
| 255 |
> EOS |
| 256 |
rebasing 3:a4256619d830 B "B" |
| 257 |
rebasing 6:8e139e245220 C tip "C" |
| 258 |
o 8: d7d1169e9b1c C |
| 259 |
|\ |
| 260 |
| o 7: 2ed0c8546285 B |
| 261 |
| |\ |
| 262 |
o | | 5: 8fdb2c1feb20 G |
| 263 |
| | | |
| 264 |
| | o 4: cd488e83d208 E |
| 265 |
| | | |
| 266 |
o | | 2: a6661b868de9 F |
| 267 |
/ / |
| 268 |
| o 1: 058c1e1fb10a D |
| 269 |
| |
| 270 |
o 0: 426bada5c675 A |
| 271 |
|
| 272 |
Move to a previous parent: |
| 273 |
|
| 274 |
$ rebasewithdag -s E -s F -s G -d 'SRC^^' <<'EOS' |
| 275 |
> H |
| 276 |
> | |
| 277 |
> D G |
| 278 |
> |/ |
| 279 |
> C F |
| 280 |
> |/ |
| 281 |
> B E # E will be ignored, since E^^ is empty |
| 282 |
> |/ |
| 283 |
> A |
| 284 |
> EOS |
| 285 |
rebasing 4:33441538d4aa F "F" |
| 286 |
rebasing 6:cf43ad9da869 G "G" |
| 287 |
rebasing 7:eef94f3b5f03 H tip "H" |
| 288 |
o 10: b3d84c6666cf H |
| 289 |
| |
| 290 |
| o 5: f585351a92f8 D |
| 291 |
|/ |
| 292 |
o 3: 26805aba1e60 C |
| 293 |
| |
| 294 |
| o 9: f7c28a1a15e2 G |
| 295 |
|/ |
| 296 |
o 1: 112478962961 B |
| 297 |
| |
| 298 |
| o 8: 02aa697facf7 F |
| 299 |
|/ |
| 300 |
| o 2: 7fb047a69f22 E |
| 301 |
|/ |
| 302 |
o 0: 426bada5c675 A |
| 303 |
|
| 304 |
Source overlaps with destination: |
| 305 |
|
| 306 |
$ rebasewithdag -s 'B+C+D' -d 'map(SRC, "B:C,C:D")' <<'EOS' |
| 307 |
> B C D |
| 308 |
> \|/ |
| 309 |
> A |
| 310 |
> EOS |
| 311 |
rebasing 2:dc0947a82db8 C "C" |
| 312 |
rebasing 1:112478962961 B "B" |
| 313 |
o 5: 5fe9935d5222 B |
| 314 |
| |
| 315 |
o 4: 12d20731b9e0 C |
| 316 |
| |
| 317 |
o 3: b18e25de2cf5 D |
| 318 |
| |
| 319 |
o 0: 426bada5c675 A |
| 320 |
|
| 321 |
Detect cycles early: |
| 322 |
|
| 323 |
$ rebasewithdag -r 'all()-Z' -d 'map(SRC, "A:B,B:C,C:D,D:B")' <<'EOS' |
| 324 |
> A B C |
| 325 |
> \|/ |
| 326 |
> | D |
| 327 |
> |/ |
| 328 |
> Z |
| 329 |
> EOS |
| 330 |
abort: source and destination form a cycle |
| 331 |
[10] |
| 332 |
|
| 333 |
Detect source is ancestor of dest in runtime: |
| 334 |
|
| 335 |
$ rebasewithdag -r 'C+B' -d 'map(SRC, "C:B,B:D")' -q <<'EOS' |
| 336 |
> D |
| 337 |
> | |
| 338 |
> B C |
| 339 |
> \| |
| 340 |
> A |
| 341 |
> EOS |
| 342 |
abort: source is ancestor of destination |
| 343 |
[10] |
| 344 |
|
| 345 |
"Already rebased" fast path still works: |
| 346 |
|
| 347 |
$ rebasewithdag -r 'all()' -d 'SRC^' <<'EOS' |
| 348 |
> E F |
| 349 |
> /| | |
| 350 |
> B C D |
| 351 |
> \|/ |
| 352 |
> A |
| 353 |
> EOS |
| 354 |
already rebased 1:112478962961 B "B" |
| 355 |
already rebased 2:dc0947a82db8 C "C" |
| 356 |
already rebased 3:b18e25de2cf5 D "D" |
| 357 |
already rebased 4:312782b8f06e E "E" |
| 358 |
already rebased 5:ad6717a6a58e F tip "F" |
| 359 |
o 5: ad6717a6a58e F |
| 360 |
| |
| 361 |
o 3: b18e25de2cf5 D |
| 362 |
| |
| 363 |
| o 4: 312782b8f06e E |
| 364 |
| |\ |
| 365 |
+---o 2: dc0947a82db8 C |
| 366 |
| | |
| 367 |
| o 1: 112478962961 B |
| 368 |
|/ |
| 369 |
o 0: 426bada5c675 A |
| 370 |
|
| 371 |
Massively rewrite the DAG: |
| 372 |
|
| 373 |
$ rebasewithdag -r 'all()' -d 'map(SRC, "A:I,I:null,H:A,B:J,J:C,C:H,D:E,F:G,G:K,K:D,E:B")' <<'EOS' |
| 374 |
> D G K |
| 375 |
> | | | |
| 376 |
> C F J |
| 377 |
> | | | |
| 378 |
> B E I |
| 379 |
> \| | |
| 380 |
> A H |
| 381 |
> EOS |
| 382 |
rebasing 4:701514e1408d I "I" |
| 383 |
rebasing 0:426bada5c675 A "A" |
| 384 |
rebasing 1:e7050b6e5048 H "H" |
| 385 |
rebasing 5:26805aba1e60 C "C" |
| 386 |
rebasing 7:cf89f86b485b J "J" |
| 387 |
rebasing 2:112478962961 B "B" |
| 388 |
rebasing 3:7fb047a69f22 E "E" |
| 389 |
rebasing 8:f585351a92f8 D "D" |
| 390 |
rebasing 10:ae41898d7875 K tip "K" |
| 391 |
rebasing 9:711f53bbef0b G "G" |
| 392 |
rebasing 6:64a8289d2492 F "F" |
| 393 |
o 21: 3735afb3713a F |
| 394 |
| |
| 395 |
o 20: 07698142d7a7 G |
| 396 |
| |
| 397 |
o 19: 33aba52e7e72 K |
| 398 |
| |
| 399 |
o 18: 9fdae89dc5a1 D |
| 400 |
| |
| 401 |
o 17: 277dda9a65ee E |
| 402 |
| |
| 403 |
o 16: 9c74fd8657ad B |
| 404 |
| |
| 405 |
o 15: 6527eb0688bb J |
| 406 |
| |
| 407 |
o 14: e94d655b928d C |
| 408 |
| |
| 409 |
o 13: 620d6d349459 H |
| 410 |
| |
| 411 |
o 12: a569a116758f A |
| 412 |
| |
| 413 |
o 11: 2bf1302f5c18 I |
| 414 |
|
| 415 |
Resolve instability: |
| 416 |
|
| 417 |
$ rebasewithdag <<'EOF' -r 'orphan()-obsolete()' -d 'max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::)' |
| 418 |
> F2 |
| 419 |
> | |
| 420 |
> J E E2 |
| 421 |
> | |/ |
| 422 |
> I2 I | E3 |
| 423 |
> \| |/ |
| 424 |
> H | G |
| 425 |
> | | | |
| 426 |
> B2 D F |
| 427 |
> | |/ # rebase: B -> B2 |
| 428 |
> N C # amend: E -> E2 |
| 429 |
> | | # amend: E2 -> E3 |
| 430 |
> M B # rebase: F -> F2 |
| 431 |
> \| # amend: I -> I2 |
| 432 |
> A |
| 433 |
> EOF |
| 434 |
6 new orphan changesets |
| 435 |
rebasing 16:5c432343bf59 J tip "J" |
| 436 |
rebasing 3:26805aba1e60 C "C" |
| 437 |
rebasing 6:f585351a92f8 D "D" |
| 438 |
rebasing 10:ffebc37c5d0b E3 "E3" |
| 439 |
rebasing 13:fb184bcfeee8 F2 "F2" |
| 440 |
rebasing 11:dc838ab4c0da G "G" |
| 441 |
o 22: 174f63d574a8 G |
| 442 |
| |
| 443 |
o 21: c9d9fbe76705 F2 |
| 444 |
| |
| 445 |
o 20: 0a03c2ede755 E3 |
| 446 |
| |
| 447 |
o 19: 228d9d2541b1 D |
| 448 |
| |
| 449 |
o 18: cd856b400c95 C |
| 450 |
| |
| 451 |
o 17: 9148200c858c J |
| 452 |
| |
| 453 |
o 15: eb74780f5094 I2 |
| 454 |
| |
| 455 |
o 12: 78309edd643f H |
| 456 |
| |
| 457 |
o 5: 4b4531bd8e1d B2 |
| 458 |
| |
| 459 |
o 4: 337c285c272b N |
| 460 |
| |
| 461 |
o 2: 699bc4b6fa22 M |
| 462 |
| |
| 463 |
o 0: 426bada5c675 A |
| 464 |
|