| 1 |
Test the "--base" flag of the rebase command. (Tests unrelated to the "--base" |
| 2 |
flag should probably live in somewhere else) |
| 3 |
|
| 4 |
$ cat >> $HGRCPATH <<EOF |
| 5 |
> [extensions] |
| 6 |
> rebase= |
| 7 |
> drawdag=$TESTDIR/drawdag.py |
| 8 |
> |
| 9 |
> [phases] |
| 10 |
> publish=False |
| 11 |
> |
| 12 |
> [alias] |
| 13 |
> tglog = log -G --template "{rev}: {node|short} {desc}" |
| 14 |
> EOF |
| 15 |
|
| 16 |
$ rebasewithdag() { |
| 17 |
> N=`"$PYTHON" -c "print($N+1)"` |
| 18 |
> hg init repo$N && cd repo$N |
| 19 |
> hg debugdrawdag |
| 20 |
> hg rebase "$@" > _rebasetmp |
| 21 |
> r=$? |
| 22 |
> grep -v 'saved backup bundle' _rebasetmp |
| 23 |
> [ $r -eq 0 ] && hg tglog |
| 24 |
> cd .. |
| 25 |
> return $r |
| 26 |
> } |
| 27 |
|
| 28 |
Single branching point, without merge: |
| 29 |
|
| 30 |
$ rebasewithdag -b D -d Z <<'EOS' |
| 31 |
> D E |
| 32 |
> |/ |
| 33 |
> Z B C # C: branching point, E should be picked |
| 34 |
> \|/ # B should not be picked |
| 35 |
> A |
| 36 |
> | |
| 37 |
> R |
| 38 |
> EOS |
| 39 |
rebasing 3:d6003a550c2c C "C" |
| 40 |
rebasing 5:4526cf523425 D "D" |
| 41 |
rebasing 6:b296604d9846 E tip "E" |
| 42 |
o 6: 4870f5e7df37 E |
| 43 |
| |
| 44 |
| o 5: dc999528138a D |
| 45 |
|/ |
| 46 |
o 4: 6b3e11729672 C |
| 47 |
| |
| 48 |
o 3: 57e70bad1ea3 Z |
| 49 |
| |
| 50 |
| o 2: c1e6b162678d B |
| 51 |
|/ |
| 52 |
o 1: 21a6c4502885 A |
| 53 |
| |
| 54 |
o 0: b41ce7760717 R |
| 55 |
|
| 56 |
Multiple branching points caused by selecting a single merge changeset: |
| 57 |
|
| 58 |
$ rebasewithdag -b E -d Z <<'EOS' |
| 59 |
> E |
| 60 |
> /| |
| 61 |
> B C D # B, C: multiple branching points |
| 62 |
> | |/ # D should not be picked |
| 63 |
> Z | / |
| 64 |
> \|/ |
| 65 |
> A |
| 66 |
> | |
| 67 |
> R |
| 68 |
> EOS |
| 69 |
rebasing 2:c1e6b162678d B "B" |
| 70 |
rebasing 3:d6003a550c2c C "C" |
| 71 |
rebasing 6:54c8f00cb91c E tip "E" |
| 72 |
o 6: 00598421b616 E |
| 73 |
|\ |
| 74 |
| o 5: 6b3e11729672 C |
| 75 |
| | |
| 76 |
o | 4: 85260910e847 B |
| 77 |
|/ |
| 78 |
o 3: 57e70bad1ea3 Z |
| 79 |
| |
| 80 |
| o 2: 8924700906fe D |
| 81 |
|/ |
| 82 |
o 1: 21a6c4502885 A |
| 83 |
| |
| 84 |
o 0: b41ce7760717 R |
| 85 |
|
| 86 |
Rebase should not extend the "--base" revset using "descendants": |
| 87 |
|
| 88 |
$ rebasewithdag -b B -d Z <<'EOS' |
| 89 |
> E |
| 90 |
> /| |
| 91 |
> Z B C # descendants(B) = B+E. With E, C will be included incorrectly |
| 92 |
> \|/ |
| 93 |
> A |
| 94 |
> | |
| 95 |
> R |
| 96 |
> EOS |
| 97 |
rebasing 2:c1e6b162678d B "B" |
| 98 |
rebasing 5:54c8f00cb91c E tip "E" |
| 99 |
o 5: e583bf3ff54c E |
| 100 |
|\ |
| 101 |
| o 4: 85260910e847 B |
| 102 |
| | |
| 103 |
| o 3: 57e70bad1ea3 Z |
| 104 |
| | |
| 105 |
o | 2: d6003a550c2c C |
| 106 |
|/ |
| 107 |
o 1: 21a6c4502885 A |
| 108 |
| |
| 109 |
o 0: b41ce7760717 R |
| 110 |
|
| 111 |
Rebase should not simplify the "--base" revset using "roots": |
| 112 |
|
| 113 |
$ rebasewithdag -b B+E -d Z <<'EOS' |
| 114 |
> E |
| 115 |
> /| |
| 116 |
> Z B C # roots(B+E) = B. Without E, C will be missed incorrectly |
| 117 |
> \|/ |
| 118 |
> A |
| 119 |
> | |
| 120 |
> R |
| 121 |
> EOS |
| 122 |
rebasing 2:c1e6b162678d B "B" |
| 123 |
rebasing 3:d6003a550c2c C "C" |
| 124 |
rebasing 5:54c8f00cb91c E tip "E" |
| 125 |
o 5: 00598421b616 E |
| 126 |
|\ |
| 127 |
| o 4: 6b3e11729672 C |
| 128 |
| | |
| 129 |
o | 3: 85260910e847 B |
| 130 |
|/ |
| 131 |
o 2: 57e70bad1ea3 Z |
| 132 |
| |
| 133 |
o 1: 21a6c4502885 A |
| 134 |
| |
| 135 |
o 0: b41ce7760717 R |
| 136 |
|
| 137 |
The destination is one of the two branching points of a merge: |
| 138 |
|
| 139 |
$ rebasewithdag -b F -d Z <<'EOS' |
| 140 |
> F |
| 141 |
> / \ |
| 142 |
> E D |
| 143 |
> / / |
| 144 |
> Z C |
| 145 |
> \ / |
| 146 |
> B |
| 147 |
> | |
| 148 |
> A |
| 149 |
> EOS |
| 150 |
nothing to rebase |
| 151 |
[1] |
| 152 |
|
| 153 |
Multiple branching points caused by multiple bases (issue5420): |
| 154 |
|
| 155 |
$ rebasewithdag -b E1+E2+C2+B1 -d Z <<'EOS' |
| 156 |
> Z E2 |
| 157 |
> | / |
| 158 |
> F E1 C2 |
| 159 |
> |/ / |
| 160 |
> E C1 B2 |
| 161 |
> |/ / |
| 162 |
> C B1 |
| 163 |
> |/ |
| 164 |
> B |
| 165 |
> | |
| 166 |
> A |
| 167 |
> | |
| 168 |
> R |
| 169 |
> EOS |
| 170 |
rebasing 3:a113dbaa660a B1 "B1" |
| 171 |
rebasing 5:06ce7b1cc8c2 B2 "B2" |
| 172 |
rebasing 6:0ac98cce32d3 C1 "C1" |
| 173 |
rebasing 8:781512f5e33d C2 "C2" |
| 174 |
rebasing 9:428d8c18f641 E1 "E1" |
| 175 |
rebasing 11:e1bf82f6b6df E2 "E2" |
| 176 |
o 12: e4a37b6fdbd2 E2 |
| 177 |
| |
| 178 |
o 11: 9675bea983df E1 |
| 179 |
| |
| 180 |
| o 10: 4faf5d4c80dc C2 |
| 181 |
| | |
| 182 |
| o 9: d4799b1ad57d C1 |
| 183 |
|/ |
| 184 |
| o 8: 772732dc64d6 B2 |
| 185 |
| | |
| 186 |
| o 7: ad3ac528a49f B1 |
| 187 |
|/ |
| 188 |
o 6: 2cbdfca6b9d5 Z |
| 189 |
| |
| 190 |
o 5: fcdb3293ec13 F |
| 191 |
| |
| 192 |
o 4: a4652bb8ac54 E |
| 193 |
| |
| 194 |
o 3: bd5548558fcf C |
| 195 |
| |
| 196 |
o 2: c1e6b162678d B |
| 197 |
| |
| 198 |
o 1: 21a6c4502885 A |
| 199 |
| |
| 200 |
o 0: b41ce7760717 R |
| 201 |
|
| 202 |
Multiple branching points with multiple merges: |
| 203 |
|
| 204 |
$ rebasewithdag -b G+P -d Z <<'EOS' |
| 205 |
> G H P |
| 206 |
> |\ /| |\ |
| 207 |
> F E D M N |
| 208 |
> \|/| /| |\ |
| 209 |
> Z C B I J K L |
| 210 |
> \|/ |/ |/ |
| 211 |
> A A A |
| 212 |
> EOS |
| 213 |
rebasing 2:dc0947a82db8 C "C" |
| 214 |
rebasing 8:4e4f9194f9f1 D "D" |
| 215 |
rebasing 9:03ca77807e91 E "E" |
| 216 |
rebasing 10:afc707c82df0 F "F" |
| 217 |
rebasing 13:690dfff91e9e G "G" |
| 218 |
rebasing 14:2893b886bb10 H "H" |
| 219 |
rebasing 3:08ebfeb61bac I "I" |
| 220 |
rebasing 4:a0a5005cec67 J "J" |
| 221 |
rebasing 5:83780307a7e8 K "K" |
| 222 |
rebasing 6:e131637a1cb6 L "L" |
| 223 |
rebasing 11:d1f6d0c3c7e4 M "M" |
| 224 |
rebasing 12:7aaec6f81888 N "N" |
| 225 |
rebasing 15:325bc8f1760d P tip "P" |
| 226 |
o 15: 6ef6a0ea3b18 P |
| 227 |
|\ |
| 228 |
| o 14: 20ba3610a7e5 N |
| 229 |
| |\ |
| 230 |
o \ \ 13: cd4f6c06d2ab M |
| 231 |
|\ \ \ |
| 232 |
| | | o 12: bca872041455 L |
| 233 |
| | | | |
| 234 |
| | o | 11: 7bbb6c8a6ad7 K |
| 235 |
| | |/ |
| 236 |
| o / 10: de0cbffe893e J |
| 237 |
| |/ |
| 238 |
o / 9: 0e710f176a88 I |
| 239 |
|/ |
| 240 |
| o 8: 52507bab39ca H |
| 241 |
| |\ |
| 242 |
| | | o 7: bb5fe4652f0d G |
| 243 |
| | |/| |
| 244 |
| | | o 6: f4ad4b31daf4 F |
| 245 |
| | | | |
| 246 |
| | o | 5: b168f85f2e78 E |
| 247 |
| | |/ |
| 248 |
| o | 4: 8d09fcdb5594 D |
| 249 |
| |\| |
| 250 |
+---o 3: ab70b4c5a9c9 C |
| 251 |
| | |
| 252 |
o | 2: 262e37e34f63 Z |
| 253 |
| | |
| 254 |
| o 1: 112478962961 B |
| 255 |
|/ |
| 256 |
o 0: 426bada5c675 A |
| 257 |
|
| 258 |
Slightly more complex merge case (mentioned in https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/091074.html): |
| 259 |
|
| 260 |
$ rebasewithdag -b A3+B3 -d Z <<'EOF' |
| 261 |
> Z C1 A3 B3 |
| 262 |
> | / / \ / \ |
| 263 |
> M3 C0 A1 A2 B1 B2 |
| 264 |
> | / | | | | |
| 265 |
> M2 M1 C1 C1 M3 |
| 266 |
> | |
| 267 |
> M1 |
| 268 |
> | |
| 269 |
> M0 |
| 270 |
> EOF |
| 271 |
rebasing 4:8817fae53c94 C0 "C0" |
| 272 |
rebasing 6:06ca5dfe3b5b B2 "B2" |
| 273 |
rebasing 7:73508237b032 C1 "C1" |
| 274 |
rebasing 9:fdb955e2faed A2 "A2" |
| 275 |
rebasing 11:4e449bd1a643 A3 "A3" |
| 276 |
rebasing 10:0a33b0519128 B1 "B1" |
| 277 |
rebasing 12:209327807c3a B3 tip "B3" |
| 278 |
o 12: ceb984566332 B3 |
| 279 |
|\ |
| 280 |
| o 11: 19d93caac497 B1 |
| 281 |
| | |
| 282 |
| | o 10: 058e73d3916b A3 |
| 283 |
| | |\ |
| 284 |
| +---o 9: 0ba13ad72234 A2 |
| 285 |
| | | |
| 286 |
| o | 8: c122c2af10c6 C1 |
| 287 |
| | | |
| 288 |
o | | 7: 74275896650e B2 |
| 289 |
| | | |
| 290 |
| o | 6: 455ba9bd3ea2 C0 |
| 291 |
|/ / |
| 292 |
o | 5: b3d7d2fda53b Z |
| 293 |
| | |
| 294 |
o | 4: 182ab6383dd7 M3 |
| 295 |
| | |
| 296 |
o | 3: 6c3f73563d5f M2 |
| 297 |
| | |
| 298 |
| o 2: 88c860fffcc2 A1 |
| 299 |
|/ |
| 300 |
o 1: bc852baa85dd M1 |
| 301 |
| |
| 302 |
o 0: dbdfc5c9bcd5 M0 |
| 303 |
|
| 304 |
Disconnected graph: |
| 305 |
|
| 306 |
$ rebasewithdag -b B -d Z <<'EOS' |
| 307 |
> B |
| 308 |
> | |
| 309 |
> Z A |
| 310 |
> EOS |
| 311 |
nothing to rebase from 112478962961 to 48b9aae0607f |
| 312 |
[1] |
| 313 |
|
| 314 |
Multiple roots. Roots are ancestors of dest: |
| 315 |
|
| 316 |
$ rebasewithdag -b B+D -d Z <<'EOF' |
| 317 |
> D Z B |
| 318 |
> \|\| |
| 319 |
> C A |
| 320 |
> EOF |
| 321 |
rebasing 2:112478962961 B "B" |
| 322 |
rebasing 3:b70f76719894 D "D" |
| 323 |
o 4: 511efad7bf13 D |
| 324 |
| |
| 325 |
| o 3: 25c4e279af62 B |
| 326 |
|/ |
| 327 |
o 2: 3a49f54d7bb1 Z |
| 328 |
|\ |
| 329 |
| o 1: 96cc3511f894 C |
| 330 |
| |
| 331 |
o 0: 426bada5c675 A |
| 332 |
|
| 333 |
Multiple roots. One root is not an ancestor of dest: |
| 334 |
|
| 335 |
$ rebasewithdag -b B+D -d Z <<'EOF' |
| 336 |
> Z B D |
| 337 |
> \|\| |
| 338 |
> A C |
| 339 |
> EOF |
| 340 |
nothing to rebase from f675d5a1c6a4+b70f76719894 to 262e37e34f63 |
| 341 |
[1] |
| 342 |
|
| 343 |
Multiple roots. One root is not an ancestor of dest. Select using a merge: |
| 344 |
|
| 345 |
$ rebasewithdag -b E -d Z <<'EOF' |
| 346 |
> E |
| 347 |
> |\ |
| 348 |
> Z B D |
| 349 |
> \|\| |
| 350 |
> A C |
| 351 |
> EOF |
| 352 |
rebasing 2:f675d5a1c6a4 B "B" |
| 353 |
rebasing 5:f68696fe6af8 E tip "E" |
| 354 |
o 5: f6e6f5081554 E |
| 355 |
|\ |
| 356 |
| o 4: 30cabcba27be B |
| 357 |
| |\ |
| 358 |
| | o 3: 262e37e34f63 Z |
| 359 |
| | | |
| 360 |
o | | 2: b70f76719894 D |
| 361 |
|/ / |
| 362 |
o / 1: 96cc3511f894 C |
| 363 |
/ |
| 364 |
o 0: 426bada5c675 A |
| 365 |
|
| 366 |
Multiple roots. Two children share two parents while dest has only one parent: |
| 367 |
|
| 368 |
$ rebasewithdag -b B+D -d Z <<'EOF' |
| 369 |
> Z B D |
| 370 |
> \|\|\ |
| 371 |
> A C A |
| 372 |
> EOF |
| 373 |
rebasing 2:f675d5a1c6a4 B "B" |
| 374 |
rebasing 3:c2a779e13b56 D "D" |
| 375 |
o 4: 5eecd056b5f8 D |
| 376 |
|\ |
| 377 |
+---o 3: 30cabcba27be B |
| 378 |
| |/ |
| 379 |
| o 2: 262e37e34f63 Z |
| 380 |
| | |
| 381 |
o | 1: 96cc3511f894 C |
| 382 |
/ |
| 383 |
o 0: 426bada5c675 A |
| 384 |
|