| 1 |
========================== |
| 2 |
Test rebase with obsolete |
| 3 |
========================== |
| 4 |
|
| 5 |
Enable obsolete |
| 6 |
|
| 7 |
$ cat >> $HGRCPATH << EOF |
| 8 |
> [command-templates] |
| 9 |
> log= {rev}:{node|short} {desc|firstline}{if(obsolete,' ({obsfate})')} |
| 10 |
> [experimental] |
| 11 |
> evolution.createmarkers=True |
| 12 |
> evolution.allowunstable=True |
| 13 |
> [phases] |
| 14 |
> publish=False |
| 15 |
> [extensions] |
| 16 |
> rebase= |
| 17 |
> drawdag=$TESTDIR/drawdag.py |
| 18 |
> strip= |
| 19 |
> EOF |
| 20 |
|
| 21 |
Skip obsolete changeset even with multiple hops |
| 22 |
----------------------------------------------- |
| 23 |
|
| 24 |
setup |
| 25 |
|
| 26 |
$ hg init obsskip |
| 27 |
$ cd obsskip |
| 28 |
$ cat << EOF >> .hg/hgrc |
| 29 |
> [experimental] |
| 30 |
> rebaseskipobsolete = True |
| 31 |
> [extensions] |
| 32 |
> strip = |
| 33 |
> EOF |
| 34 |
$ echo A > A |
| 35 |
$ hg add A |
| 36 |
$ hg commit -m A |
| 37 |
$ echo B > B |
| 38 |
$ hg add B |
| 39 |
$ hg commit -m B0 |
| 40 |
$ hg commit --amend -m B1 |
| 41 |
$ hg commit --amend -m B2 |
| 42 |
$ hg up --hidden 'desc(B0)' |
| 43 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 44 |
updated to hidden changeset a8b11f55fb19 |
| 45 |
(hidden revision 'a8b11f55fb19' was rewritten as: 261e70097290) |
| 46 |
$ echo C > C |
| 47 |
$ hg add C |
| 48 |
$ hg commit -m C |
| 49 |
1 new orphan changesets |
| 50 |
created new head |
| 51 |
$ hg log -G |
| 52 |
@ 4:212cb178bcbb C |
| 53 |
| |
| 54 |
| o 3:261e70097290 B2 |
| 55 |
| | |
| 56 |
x | 1:a8b11f55fb19 B0 (rewritten using amend as 3:261e70097290) |
| 57 |
|/ |
| 58 |
o 0:4a2df7238c3b A |
| 59 |
|
| 60 |
|
| 61 |
Rebase finds its way in a chain of marker |
| 62 |
|
| 63 |
$ hg rebase -d 'desc(B2)' |
| 64 |
note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 3:261e70097290 "B2" |
| 65 |
rebasing 4:212cb178bcbb tip "C" |
| 66 |
|
| 67 |
Even when the chain include missing node |
| 68 |
|
| 69 |
$ hg up --hidden 'desc(B0)' |
| 70 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 71 |
updated to hidden changeset a8b11f55fb19 |
| 72 |
(hidden revision 'a8b11f55fb19' was rewritten as: 261e70097290) |
| 73 |
$ echo D > D |
| 74 |
$ hg add D |
| 75 |
$ hg commit -m D |
| 76 |
1 new orphan changesets |
| 77 |
created new head |
| 78 |
$ hg --hidden strip -r 'desc(B1)' |
| 79 |
saved backup bundle to $TESTTMP/obsskip/.hg/strip-backup/86f6414ccda7-b1c452ee-backup.hg |
| 80 |
1 new orphan changesets |
| 81 |
$ hg log -G |
| 82 |
@ 5:1a79b7535141 D |
| 83 |
| |
| 84 |
| o 4:ff2c4d47b71d C |
| 85 |
| | |
| 86 |
| o 2:261e70097290 B2 |
| 87 |
| | |
| 88 |
x | 1:a8b11f55fb19 B0 (rewritten using amend as 2:261e70097290) |
| 89 |
|/ |
| 90 |
o 0:4a2df7238c3b A |
| 91 |
|
| 92 |
|
| 93 |
$ hg rebase -d 'desc(B2)' |
| 94 |
note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 2:261e70097290 "B2" |
| 95 |
rebasing 5:1a79b7535141 tip "D" |
| 96 |
$ hg up 4 |
| 97 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 98 |
$ echo "O" > O |
| 99 |
$ hg add O |
| 100 |
$ hg commit -m O |
| 101 |
$ echo "P" > P |
| 102 |
$ hg add P |
| 103 |
$ hg commit -m P |
| 104 |
$ hg log -G |
| 105 |
@ 8:8d47583e023f P |
| 106 |
| |
| 107 |
o 7:360bbaa7d3ce O |
| 108 |
| |
| 109 |
| o 6:9c48361117de D |
| 110 |
| | |
| 111 |
o | 4:ff2c4d47b71d C |
| 112 |
|/ |
| 113 |
o 2:261e70097290 B2 |
| 114 |
| |
| 115 |
o 0:4a2df7238c3b A |
| 116 |
|
| 117 |
$ hg debugobsolete `hg log -r 7 -T '{node}\n'` --config experimental.evolution=true |
| 118 |
1 new obsolescence markers |
| 119 |
obsoleted 1 changesets |
| 120 |
1 new orphan changesets |
| 121 |
$ hg rebase -d 6 -r "4::" |
| 122 |
rebasing 4:ff2c4d47b71d "C" |
| 123 |
note: not rebasing 7:360bbaa7d3ce "O", it has no successor |
| 124 |
rebasing 8:8d47583e023f tip "P" |
| 125 |
|
| 126 |
If all the changeset to be rebased are obsolete and present in the destination, we |
| 127 |
should display a friendly error message |
| 128 |
|
| 129 |
$ hg log -G |
| 130 |
@ 10:121d9e3bc4c6 P |
| 131 |
| |
| 132 |
o 9:4be60e099a77 C |
| 133 |
| |
| 134 |
o 6:9c48361117de D |
| 135 |
| |
| 136 |
o 2:261e70097290 B2 |
| 137 |
| |
| 138 |
o 0:4a2df7238c3b A |
| 139 |
|
| 140 |
|
| 141 |
$ hg up 9 |
| 142 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 143 |
$ echo "non-relevant change" > nonrelevant |
| 144 |
$ hg add nonrelevant |
| 145 |
$ hg commit -m nonrelevant |
| 146 |
created new head |
| 147 |
$ hg debugobsolete `hg log -r 11 -T '{node}\n'` --config experimental.evolution=true |
| 148 |
1 new obsolescence markers |
| 149 |
obsoleted 1 changesets |
| 150 |
$ hg log -G |
| 151 |
@ 11:f44da1f4954c nonrelevant (pruned) |
| 152 |
| |
| 153 |
| o 10:121d9e3bc4c6 P |
| 154 |
|/ |
| 155 |
o 9:4be60e099a77 C |
| 156 |
| |
| 157 |
o 6:9c48361117de D |
| 158 |
| |
| 159 |
o 2:261e70097290 B2 |
| 160 |
| |
| 161 |
o 0:4a2df7238c3b A |
| 162 |
|
| 163 |
$ hg rebase -r . -d 10 |
| 164 |
note: not rebasing 11:f44da1f4954c tip "nonrelevant", it has no successor |
| 165 |
|
| 166 |
If a rebase is going to create divergence, it should abort |
| 167 |
|
| 168 |
$ hg log -G |
| 169 |
@ 10:121d9e3bc4c6 P |
| 170 |
| |
| 171 |
o 9:4be60e099a77 C |
| 172 |
| |
| 173 |
o 6:9c48361117de D |
| 174 |
| |
| 175 |
o 2:261e70097290 B2 |
| 176 |
| |
| 177 |
o 0:4a2df7238c3b A |
| 178 |
|
| 179 |
|
| 180 |
$ hg up 9 |
| 181 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 182 |
$ echo "john" > doe |
| 183 |
$ hg add doe |
| 184 |
$ hg commit -m "john doe" |
| 185 |
created new head |
| 186 |
$ hg up 10 |
| 187 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 188 |
$ echo "foo" > bar |
| 189 |
$ hg add bar |
| 190 |
$ hg commit --amend -m "10'" |
| 191 |
$ hg up 10 --hidden |
| 192 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 193 |
updated to hidden changeset 121d9e3bc4c6 |
| 194 |
(hidden revision '121d9e3bc4c6' was rewritten as: 77d874d096a2) |
| 195 |
$ echo "bar" > foo |
| 196 |
$ hg add foo |
| 197 |
$ hg commit -m "bar foo" |
| 198 |
1 new orphan changesets |
| 199 |
created new head |
| 200 |
$ hg log -G |
| 201 |
@ 14:73568ab6879d bar foo |
| 202 |
| |
| 203 |
| o 13:77d874d096a2 10' |
| 204 |
| | |
| 205 |
| | o 12:3eb461388009 john doe |
| 206 |
| |/ |
| 207 |
x | 10:121d9e3bc4c6 P (rewritten using amend as 13:77d874d096a2) |
| 208 |
|/ |
| 209 |
o 9:4be60e099a77 C |
| 210 |
| |
| 211 |
o 6:9c48361117de D |
| 212 |
| |
| 213 |
o 2:261e70097290 B2 |
| 214 |
| |
| 215 |
o 0:4a2df7238c3b A |
| 216 |
|
| 217 |
$ hg summary |
| 218 |
parent: 14:73568ab6879d tip (orphan) |
| 219 |
bar foo |
| 220 |
branch: default |
| 221 |
commit: (clean) |
| 222 |
update: 2 new changesets, 3 branch heads (merge) |
| 223 |
phases: 8 draft |
| 224 |
orphan: 1 changesets |
| 225 |
$ hg rebase -s 10 -d 12 |
| 226 |
abort: this rebase will cause divergences from: 121d9e3bc4c6 |
| 227 |
(to force the rebase please set experimental.evolution.allowdivergence=True) |
| 228 |
[20] |
| 229 |
$ hg log -G |
| 230 |
@ 14:73568ab6879d bar foo |
| 231 |
| |
| 232 |
| o 13:77d874d096a2 10' |
| 233 |
| | |
| 234 |
| | o 12:3eb461388009 john doe |
| 235 |
| |/ |
| 236 |
x | 10:121d9e3bc4c6 P (rewritten using amend as 13:77d874d096a2) |
| 237 |
|/ |
| 238 |
o 9:4be60e099a77 C |
| 239 |
| |
| 240 |
o 6:9c48361117de D |
| 241 |
| |
| 242 |
o 2:261e70097290 B2 |
| 243 |
| |
| 244 |
o 0:4a2df7238c3b A |
| 245 |
|
| 246 |
With experimental.evolution.allowdivergence=True, rebase can create divergence |
| 247 |
|
| 248 |
$ hg rebase -s 10 -d 12 --config experimental.evolution.allowdivergence=True |
| 249 |
rebasing 10:121d9e3bc4c6 "P" |
| 250 |
rebasing 14:73568ab6879d tip "bar foo" |
| 251 |
2 new content-divergent changesets |
| 252 |
$ hg summary |
| 253 |
parent: 16:61bd55f69bc4 tip |
| 254 |
bar foo |
| 255 |
branch: default |
| 256 |
commit: (clean) |
| 257 |
update: 1 new changesets, 2 branch heads (merge) |
| 258 |
phases: 8 draft |
| 259 |
content-divergent: 2 changesets |
| 260 |
|
| 261 |
rebase --continue + skipped rev because their successors are in destination |
| 262 |
we make a change in trunk and work on conflicting changes to make rebase abort. |
| 263 |
|
| 264 |
$ hg log -G -r 16:: |
| 265 |
@ 16:61bd55f69bc4 bar foo |
| 266 |
| |
| 267 |
~ |
| 268 |
|
| 269 |
Create the two changes in trunk |
| 270 |
$ printf "a" > willconflict |
| 271 |
$ hg add willconflict |
| 272 |
$ hg commit -m "willconflict first version" |
| 273 |
|
| 274 |
$ printf "dummy" > C |
| 275 |
$ hg commit -m "dummy change successor" |
| 276 |
|
| 277 |
Create the changes that we will rebase |
| 278 |
$ hg update -C 16 -q |
| 279 |
$ printf "b" > willconflict |
| 280 |
$ hg add willconflict |
| 281 |
$ hg commit -m "willconflict second version" |
| 282 |
created new head |
| 283 |
$ printf "dummy" > K |
| 284 |
$ hg add K |
| 285 |
$ hg commit -m "dummy change" |
| 286 |
$ printf "dummy" > L |
| 287 |
$ hg add L |
| 288 |
$ hg commit -m "dummy change" |
| 289 |
$ hg debugobsolete `hg log -r ".^" -T '{node}'` `hg log -r 18 -T '{node}'` --config experimental.evolution=true |
| 290 |
1 new obsolescence markers |
| 291 |
obsoleted 1 changesets |
| 292 |
1 new orphan changesets |
| 293 |
|
| 294 |
$ hg log -G -r 16:: |
| 295 |
@ 21:7bdc8a87673d dummy change |
| 296 |
| |
| 297 |
x 20:8b31da3c4919 dummy change (rewritten as 18:601db7a18f51) |
| 298 |
| |
| 299 |
o 19:b82fb57ea638 willconflict second version |
| 300 |
| |
| 301 |
| o 18:601db7a18f51 dummy change successor |
| 302 |
| | |
| 303 |
| o 17:357ddf1602d5 willconflict first version |
| 304 |
|/ |
| 305 |
o 16:61bd55f69bc4 bar foo |
| 306 |
| |
| 307 |
~ |
| 308 |
$ hg rebase -r ".^^ + .^ + ." -d 18 |
| 309 |
rebasing 19:b82fb57ea638 "willconflict second version" |
| 310 |
merging willconflict |
| 311 |
warning: conflicts while merging willconflict! (edit, then use 'hg resolve --mark') |
| 312 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 313 |
[240] |
| 314 |
|
| 315 |
$ hg resolve --mark willconflict |
| 316 |
(no more unresolved files) |
| 317 |
continue: hg rebase --continue |
| 318 |
$ hg rebase --continue |
| 319 |
rebasing 19:b82fb57ea638 "willconflict second version" |
| 320 |
note: not rebasing 20:8b31da3c4919 "dummy change", already in destination as 18:601db7a18f51 "dummy change successor" |
| 321 |
rebasing 21:7bdc8a87673d tip "dummy change" |
| 322 |
$ cd .. |
| 323 |
|
| 324 |
Can rebase pruned and rewritten commits with --keep |
| 325 |
|
| 326 |
$ hg init keep |
| 327 |
$ cd keep |
| 328 |
$ hg debugdrawdag <<'EOS' |
| 329 |
> D |
| 330 |
> | |
| 331 |
> C |
| 332 |
> | |
| 333 |
> F B E # prune: B |
| 334 |
> \|/ # rebase: C -> E |
| 335 |
> A |
| 336 |
> EOS |
| 337 |
1 new orphan changesets |
| 338 |
|
| 339 |
$ hg rebase -b D -d F --keep |
| 340 |
rebasing 1:112478962961 B "B" |
| 341 |
rebasing 4:26805aba1e60 C "C" |
| 342 |
rebasing 5:f585351a92f8 D tip "D" |
| 343 |
|
| 344 |
$ cd .. |