| 1 |
Testing changing branch on commits |
| 2 |
================================== |
| 3 |
|
| 4 |
#testcases bm-v2 bm-v3 |
| 5 |
|
| 6 |
#if bm-v3 |
| 7 |
$ cat <<EOF >> $HGRCPATH |
| 8 |
> [experimental] |
| 9 |
> branch-cache-v3=yes |
| 10 |
> EOF |
| 11 |
#else |
| 12 |
$ cat <<EOF >> $HGRCPATH |
| 13 |
> [experimental] |
| 14 |
> branch-cache-v3=no |
| 15 |
> EOF |
| 16 |
#endif |
| 17 |
|
| 18 |
Setup |
| 19 |
|
| 20 |
$ cat >> $HGRCPATH << EOF |
| 21 |
> [alias] |
| 22 |
> glog = log -G -T "{rev}:{node|short} {desc}\n{branch} ({bookmarks})" |
| 23 |
> [experimental] |
| 24 |
> evolution = createmarkers |
| 25 |
> [extensions] |
| 26 |
> rebase= |
| 27 |
> EOF |
| 28 |
|
| 29 |
$ hg init repo |
| 30 |
$ cd repo |
| 31 |
$ for ch in a b c d e; do echo foo >> $ch; hg ci -Aqm "Added "$ch; done |
| 32 |
$ hg glog |
| 33 |
@ 4:aa98ab95a928 Added e |
| 34 |
| default () |
| 35 |
o 3:62615734edd5 Added d |
| 36 |
| default () |
| 37 |
o 2:28ad74487de9 Added c |
| 38 |
| default () |
| 39 |
o 1:29becc82797a Added b |
| 40 |
| default () |
| 41 |
o 0:18d04c59bb5d Added a |
| 42 |
default () |
| 43 |
|
| 44 |
$ hg branches |
| 45 |
default 4:aa98ab95a928 |
| 46 |
|
| 47 |
Try without passing a new branch name |
| 48 |
|
| 49 |
$ hg branch -r . |
| 50 |
abort: no branch name specified for the revisions |
| 51 |
[10] |
| 52 |
|
| 53 |
Setting an invalid branch name |
| 54 |
|
| 55 |
$ hg branch -r . a:b |
| 56 |
abort: ':' cannot be used in a name |
| 57 |
[10] |
| 58 |
$ hg branch -r . tip |
| 59 |
abort: the name 'tip' is reserved |
| 60 |
[10] |
| 61 |
$ hg branch -r . 1234 |
| 62 |
abort: cannot use an integer as a name |
| 63 |
[10] |
| 64 |
|
| 65 |
Change on non-linear set of commits |
| 66 |
|
| 67 |
$ hg branch -r 2 -r 4 foo |
| 68 |
abort: cannot change branch of non-linear revisions |
| 69 |
[10] |
| 70 |
|
| 71 |
Change in middle of the stack (linear commits) |
| 72 |
|
| 73 |
$ hg branch -r 1::3 foo |
| 74 |
abort: cannot change branch of changeset, as that will orphan 1 descendants |
| 75 |
(see 'hg help evolution.instability') |
| 76 |
[10] |
| 77 |
|
| 78 |
Change with dirty working directory |
| 79 |
|
| 80 |
$ echo bar > a |
| 81 |
$ hg branch -r . foo |
| 82 |
abort: uncommitted changes |
| 83 |
[20] |
| 84 |
|
| 85 |
$ hg revert --all |
| 86 |
reverting a |
| 87 |
|
| 88 |
Change on empty revision set |
| 89 |
|
| 90 |
$ hg branch -r 'draft() - all()' foo |
| 91 |
abort: empty revision set |
| 92 |
[10] |
| 93 |
|
| 94 |
Changing branch on linear set of commits from head |
| 95 |
|
| 96 |
Without obsmarkers |
| 97 |
|
| 98 |
$ hg branch -r 3:4 foo --config experimental.evolution=! |
| 99 |
changed branch on 2 changesets |
| 100 |
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/62615734edd5-e86bd13a-branch-change.hg |
| 101 |
$ hg glog |
| 102 |
@ 4:3938acfb5c0f Added e |
| 103 |
| foo () |
| 104 |
o 3:9435da006bdc Added d |
| 105 |
| foo () |
| 106 |
o 2:28ad74487de9 Added c |
| 107 |
| default () |
| 108 |
o 1:29becc82797a Added b |
| 109 |
| default () |
| 110 |
o 0:18d04c59bb5d Added a |
| 111 |
default () |
| 112 |
|
| 113 |
$ hg branches |
| 114 |
foo 4:3938acfb5c0f |
| 115 |
default 2:28ad74487de9 (inactive) |
| 116 |
|
| 117 |
With obsmarkers |
| 118 |
|
| 119 |
$ hg branch -r 3::4 bar |
| 120 |
changed branch on 2 changesets |
| 121 |
$ hg glog |
| 122 |
@ 6:7c1991464886 Added e |
| 123 |
| bar () |
| 124 |
o 5:1ea05e93925f Added d |
| 125 |
| bar () |
| 126 |
o 2:28ad74487de9 Added c |
| 127 |
| default () |
| 128 |
o 1:29becc82797a Added b |
| 129 |
| default () |
| 130 |
o 0:18d04c59bb5d Added a |
| 131 |
default () |
| 132 |
|
| 133 |
$ hg branches |
| 134 |
bar 6:7c1991464886 |
| 135 |
default 2:28ad74487de9 (inactive) |
| 136 |
|
| 137 |
Change branch name to an existing branch |
| 138 |
|
| 139 |
$ hg branch -r . default |
| 140 |
abort: a branch of the same name already exists |
| 141 |
[10] |
| 142 |
|
| 143 |
Changing on a branch head which is not topological head |
| 144 |
|
| 145 |
$ hg branch -r 2 stable |
| 146 |
abort: cannot change branch of changeset, as that will orphan 2 descendants |
| 147 |
(see 'hg help evolution.instability') |
| 148 |
[10] |
| 149 |
|
| 150 |
Enabling the allowunstable config and trying to change branch on a branch head |
| 151 |
which is not a topological head |
| 152 |
|
| 153 |
$ echo "[experimental]" >> .hg/hgrc |
| 154 |
$ echo "evolution.allowunstable=yes" >> .hg/hgrc |
| 155 |
$ hg branch -r 2 foo |
| 156 |
changed branch on 1 changesets |
| 157 |
2 new orphan changesets |
| 158 |
|
| 159 |
Changing branch of an obsoleted changeset |
| 160 |
|
| 161 |
$ hg branch -r 4 foobar |
| 162 |
abort: hidden revision '4' was rewritten as: 7c1991464886 |
| 163 |
(use --hidden to access hidden revisions) |
| 164 |
[10] |
| 165 |
|
| 166 |
$ hg branch -r 4 --hidden foobar |
| 167 |
abort: cannot change branch of 3938acfb5c0f, as that creates content-divergence with 7c1991464886 |
| 168 |
(add --verbose for details or see 'hg help evolution.instability') |
| 169 |
[10] |
| 170 |
|
| 171 |
Make sure bookmark movement is correct |
| 172 |
|
| 173 |
$ hg bookmark b1 |
| 174 |
$ hg glog -r '.^::' |
| 175 |
@ 6:7c1991464886 Added e |
| 176 |
| bar (b1) |
| 177 |
* 5:1ea05e93925f Added d |
| 178 |
| bar () |
| 179 |
~ |
| 180 |
|
| 181 |
$ hg branch -r '(.^)::' wat --debug |
| 182 |
changing branch of '1ea05e93925f806d875a2163f9b76764be644636' from 'bar' to 'wat' |
| 183 |
committing files: |
| 184 |
d |
| 185 |
committing manifest |
| 186 |
committing changelog |
| 187 |
new node id is 343660ccab7400da637bd6a211d07f413536d718 |
| 188 |
changing branch of '7c19914648869f5b02fc7fed31ddee9783fdd680' from 'bar' to 'wat' |
| 189 |
committing files: |
| 190 |
e |
| 191 |
committing manifest |
| 192 |
committing changelog |
| 193 |
new node id is de1404b45a69f8cc6437d7679033ee33e9efb4ba |
| 194 |
moving bookmarks ['b1'] from 7c19914648869f5b02fc7fed31ddee9783fdd680 to de1404b45a69f8cc6437d7679033ee33e9efb4ba |
| 195 |
resolving manifests |
| 196 |
branchmerge: False, force: False, partial: False |
| 197 |
ancestor: 7c1991464886, local: 7c1991464886+, remote: de1404b45a69 |
| 198 |
starting 4 threads for background file closing (?) |
| 199 |
changed branch on 2 changesets |
| 200 |
updating the branch cache |
| 201 |
invalid branch cache (served): tip differs |
| 202 |
invalid branch cache (served.hidden): tip differs |
| 203 |
|
| 204 |
$ hg glog -r '(.^)::' |
| 205 |
@ 9:de1404b45a69 Added e |
| 206 |
| wat (b1) |
| 207 |
* 8:343660ccab74 Added d |
| 208 |
| wat () |
| 209 |
~ |
| 210 |
|
| 211 |
Make sure phase handling is correct |
| 212 |
|
| 213 |
$ echo foo >> bar |
| 214 |
$ hg ci -Aqm "added bar" --secret |
| 215 |
1 new orphan changesets |
| 216 |
$ hg glog -r . |
| 217 |
@ 10:8ad1294c1660 added bar |
| 218 |
| wat (b1) |
| 219 |
~ |
| 220 |
$ hg branch -r . secret |
| 221 |
changed branch on 1 changesets |
| 222 |
$ hg phase -r . |
| 223 |
11: secret |
| 224 |
|
| 225 |
$ hg branches |
| 226 |
secret 11:38a9b2d53f98 |
| 227 |
foo 7:8a4729a5e2b8 |
| 228 |
wat 9:de1404b45a69 (inactive) |
| 229 |
default 1:29becc82797a (inactive) |
| 230 |
$ hg branch |
| 231 |
secret |
| 232 |
|
| 233 |
Changing branch of another head, different from one on which we are |
| 234 |
|
| 235 |
$ hg glog |
| 236 |
@ 11:38a9b2d53f98 added bar |
| 237 |
| secret (b1) |
| 238 |
* 9:de1404b45a69 Added e |
| 239 |
| wat () |
| 240 |
* 8:343660ccab74 Added d |
| 241 |
| wat () |
| 242 |
| o 7:8a4729a5e2b8 Added c |
| 243 |
| | foo () |
| 244 |
x | 2:28ad74487de9 Added c |
| 245 |
|/ default () |
| 246 |
o 1:29becc82797a Added b |
| 247 |
| default () |
| 248 |
o 0:18d04c59bb5d Added a |
| 249 |
default () |
| 250 |
|
| 251 |
$ hg branch |
| 252 |
secret |
| 253 |
|
| 254 |
$ hg branch -r 7 foobar |
| 255 |
changed branch on 1 changesets |
| 256 |
|
| 257 |
The current branch must be preserved |
| 258 |
$ hg branch |
| 259 |
secret |
| 260 |
|
| 261 |
Changing branch on multiple heads at once |
| 262 |
|
| 263 |
$ hg rebase -s 8 -d 12 --keepbranches -q |
| 264 |
|
| 265 |
$ hg rebase -s 14 -d 1 --keepbranches -q |
| 266 |
|
| 267 |
$ hg branch -r 0: stable |
| 268 |
changed branch on 6 changesets |
| 269 |
$ hg glog |
| 270 |
@ 23:6a5ddbcfb870 added bar |
| 271 |
| stable (b1) |
| 272 |
o 22:baedc6e98a67 Added e |
| 273 |
| stable () |
| 274 |
| o 21:99ac7bf8aad1 Added d |
| 275 |
| | stable () |
| 276 |
| o 20:0ecb4d39c4bd Added c |
| 277 |
|/ stable () |
| 278 |
o 19:fd45b986b109 Added b |
| 279 |
| stable () |
| 280 |
o 18:204d2769eca2 Added a |
| 281 |
stable () |
| 282 |
|
| 283 |
$ hg branches |
| 284 |
stable 23:6a5ddbcfb870 |
| 285 |
|
| 286 |
$ hg branch |
| 287 |
stable |
| 288 |
|
| 289 |
Changing to same branch is no-op |
| 290 |
|
| 291 |
$ hg branch -r 19::21 stable |
| 292 |
changed branch on 0 changesets |
| 293 |
|
| 294 |
Changing branch name to existing branch name if the branch of parent of root of |
| 295 |
revs is same as the new branch name |
| 296 |
|
| 297 |
$ hg branch -r 20::21 bugfix |
| 298 |
changed branch on 2 changesets |
| 299 |
$ hg glog |
| 300 |
o 25:714defe1cf34 Added d |
| 301 |
| bugfix () |
| 302 |
o 24:98394def28fc Added c |
| 303 |
| bugfix () |
| 304 |
| @ 23:6a5ddbcfb870 added bar |
| 305 |
| | stable (b1) |
| 306 |
| o 22:baedc6e98a67 Added e |
| 307 |
|/ stable () |
| 308 |
o 19:fd45b986b109 Added b |
| 309 |
| stable () |
| 310 |
o 18:204d2769eca2 Added a |
| 311 |
stable () |
| 312 |
|
| 313 |
$ hg branch -r 24:25 stable |
| 314 |
changed branch on 2 changesets |
| 315 |
$ hg glog |
| 316 |
o 27:4ec342341562 Added d |
| 317 |
| stable () |
| 318 |
o 26:83f48859c2de Added c |
| 319 |
| stable () |
| 320 |
| @ 23:6a5ddbcfb870 added bar |
| 321 |
| | stable (b1) |
| 322 |
| o 22:baedc6e98a67 Added e |
| 323 |
|/ stable () |
| 324 |
o 19:fd45b986b109 Added b |
| 325 |
| stable () |
| 326 |
o 18:204d2769eca2 Added a |
| 327 |
stable () |
| 328 |
|
| 329 |
Changing branch of a merge commit |
| 330 |
|
| 331 |
$ hg branch -q ghi |
| 332 |
$ echo f > f |
| 333 |
$ hg ci -qAm 'Added f' |
| 334 |
$ hg up -q 27 |
| 335 |
$ hg branch -q jkl |
| 336 |
$ echo g > g |
| 337 |
$ hg ci -qAm 'Added g' |
| 338 |
$ hg glog -r 'heads(:)' |
| 339 |
@ 29:6bc1c6c2c9da Added g |
| 340 |
| jkl () |
| 341 |
~ |
| 342 |
o 28:2f1019bd29d2 Added f |
| 343 |
| ghi (b1) |
| 344 |
~ |
| 345 |
|
| 346 |
$ hg branch -q default |
| 347 |
$ hg merge -r 28 |
| 348 |
4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 349 |
(branch merge, don't forget to commit) |
| 350 |
$ hg branch -r . abcd |
| 351 |
abort: outstanding uncommitted merge |
| 352 |
[20] |
| 353 |
|
| 354 |
$ hg ci -m "Merge commit" |
| 355 |
$ hg glog -r 'parents(.)::' |
| 356 |
@ 30:4d56e6b1eb6b Merge commit |
| 357 |
|\ default () |
| 358 |
| o 29:6bc1c6c2c9da Added g |
| 359 |
| | jkl () |
| 360 |
| ~ |
| 361 |
o 28:2f1019bd29d2 Added f |
| 362 |
| ghi (b1) |
| 363 |
~ |
| 364 |
|
| 365 |
$ hg branch -r . ghi |
| 366 |
changed branch on 1 changesets |
| 367 |
$ hg branch -r . jkl |
| 368 |
changed branch on 1 changesets |
| 369 |
$ hg branch -r . default |
| 370 |
changed branch on 1 changesets |
| 371 |
$ hg branch -r . stable |
| 372 |
abort: a branch of the same name already exists |
| 373 |
[10] |
| 374 |
|
| 375 |
$ hg branch -r . stable --force |
| 376 |
changed branch on 1 changesets |
| 377 |
$ hg branches |
| 378 |
stable 34:606538977fa6 |
| 379 |
jkl 29:6bc1c6c2c9da (inactive) |
| 380 |
ghi 28:2f1019bd29d2 (inactive) |
| 381 |
|
| 382 |
Changesets already having the requested branch name must still be recreated on |
| 383 |
top of changed ancestors. In the following example, the tip already has the |
| 384 |
"stable" branch name, while its parents have a different branch name. The other |
| 385 |
changesets also have the "stable" branch name. When the branch name of all |
| 386 |
changesets is requested to be "stable", the two parents of the tip need to be |
| 387 |
recreated with the "stable" branch name and the tip needs to be recreated with |
| 388 |
the changed parents. The other changesets stay untouched. |
| 389 |
|
| 390 |
$ hg log -r '(not branch("stable"))' -T '{node}\n' > not-stable.nodes |
| 391 |
$ hg glog -r 'nodefromfile("not-stable.nodes")::' |
| 392 |
@ 34:606538977fa6 Merge commit |
| 393 |
|\ stable () |
| 394 |
| o 29:6bc1c6c2c9da Added g |
| 395 |
| | jkl () |
| 396 |
| ~ |
| 397 |
o 28:2f1019bd29d2 Added f |
| 398 |
| ghi (b1) |
| 399 |
~ |
| 400 |
$ hg branch -r 'all()' stable --force |
| 401 |
changed branch on 2 changesets |
| 402 |
$ hg log -r 'not branch("stable")' |
| 403 |
$ hg log --hidden -T '{node}\n' \ |
| 404 |
> -r 'successors(nodefromfile("not-stable.nodes")) - hidden()' \ |
| 405 |
> > now-stable.nodes |
| 406 |
$ hg glog -r 'nodefromfile("now-stable.nodes")::' |
| 407 |
@ 37:7a416ed90703 Merge commit |
| 408 |
|\ stable () |
| 409 |
| o 36:b44a3dbb5c89 Added g |
| 410 |
| | stable () |
| 411 |
| ~ |
| 412 |
o 35:966c5d002f56 Added f |
| 413 |
| stable (b1) |
| 414 |
~ |
| 415 |
|
| 416 |
$ rm not-stable.nodes |
| 417 |
|
| 418 |
Changing branch on public changeset |
| 419 |
|
| 420 |
$ hg phase -r . -p |
| 421 |
$ hg branch -r . def |
| 422 |
abort: cannot change branch of public changesets: 7a416ed90703 |
| 423 |
(see 'hg help phases' for details) |
| 424 |
[10] |
| 425 |
|
| 426 |
The previous series of branch-changing commands should keep the contents unchanged |
| 427 |
|
| 428 |
$ hg status --hidden --rev . --rev 4d56e6b1eb6b |
| 429 |
$ hg status --hidden --change 4d56e6b1eb6b |
| 430 |
A a.orig |
| 431 |
A bar |
| 432 |
A e |
| 433 |
A f |
| 434 |
$ hg status --change . |
| 435 |
A a.orig |
| 436 |
A bar |
| 437 |
A e |
| 438 |
A f |
| 439 |
$ hg diff --hidden --from 4d56e6b1eb6b --to . |
| 440 |
$ hg diff --hidden --change 4d56e6b1eb6b |
| 441 |
diff -r 6bc1c6c2c9da -r 4d56e6b1eb6b a.orig |
| 442 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 443 |
+++ b/a.orig Thu Jan 01 00:00:00 1970 +0000 |
| 444 |
@@ -0,0 +1,1 @@ |
| 445 |
+bar |
| 446 |
diff -r 6bc1c6c2c9da -r 4d56e6b1eb6b bar |
| 447 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 448 |
+++ b/bar Thu Jan 01 00:00:00 1970 +0000 |
| 449 |
@@ -0,0 +1,1 @@ |
| 450 |
+foo |
| 451 |
diff -r 6bc1c6c2c9da -r 4d56e6b1eb6b e |
| 452 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 453 |
+++ b/e Thu Jan 01 00:00:00 1970 +0000 |
| 454 |
@@ -0,0 +1,1 @@ |
| 455 |
+foo |
| 456 |
diff -r 6bc1c6c2c9da -r 4d56e6b1eb6b f |
| 457 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 458 |
+++ b/f Thu Jan 01 00:00:00 1970 +0000 |
| 459 |
@@ -0,0 +1,1 @@ |
| 460 |
+f |
| 461 |
$ hg diff --change . |
| 462 |
diff -r b44a3dbb5c89 -r 7a416ed90703 a.orig |
| 463 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 464 |
+++ b/a.orig Thu Jan 01 00:00:00 1970 +0000 |
| 465 |
@@ -0,0 +1,1 @@ |
| 466 |
+bar |
| 467 |
diff -r b44a3dbb5c89 -r 7a416ed90703 bar |
| 468 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 469 |
+++ b/bar Thu Jan 01 00:00:00 1970 +0000 |
| 470 |
@@ -0,0 +1,1 @@ |
| 471 |
+foo |
| 472 |
diff -r b44a3dbb5c89 -r 7a416ed90703 e |
| 473 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 474 |
+++ b/e Thu Jan 01 00:00:00 1970 +0000 |
| 475 |
@@ -0,0 +1,1 @@ |
| 476 |
+foo |
| 477 |
diff -r b44a3dbb5c89 -r 7a416ed90703 f |
| 478 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 479 |
+++ b/f Thu Jan 01 00:00:00 1970 +0000 |
| 480 |
@@ -0,0 +1,1 @@ |
| 481 |
+f |
| 482 |
|
| 483 |
Merge commit with conflicts, with evolution and without |
| 484 |
|
| 485 |
$ mklozenge() { |
| 486 |
> echo foo > a |
| 487 |
> hg ci -qAm foo |
| 488 |
> echo bar > a |
| 489 |
> hg ci -qm bar |
| 490 |
> hg up -q '.^' |
| 491 |
> echo baz > a |
| 492 |
> hg ci -qm baz |
| 493 |
> hg merge -q -t :local |
| 494 |
> echo neither > a |
| 495 |
> hg ci -qm neither |
| 496 |
> } |
| 497 |
|
| 498 |
$ cd .. |
| 499 |
$ hg init merge-with-evolution |
| 500 |
$ cd merge-with-evolution |
| 501 |
$ mklozenge |
| 502 |
|
| 503 |
$ hg branch -r '(.^)::' abc |
| 504 |
changed branch on 2 changesets |
| 505 |
$ hg glog |
| 506 |
@ 5:c07fa8b34d54 neither |
| 507 |
|\ abc () |
| 508 |
| o 4:f2aa51777cc9 baz |
| 509 |
| | abc () |
| 510 |
o | 1:2e33c4f0856b bar |
| 511 |
|/ default () |
| 512 |
o 0:91cfb6004abf foo |
| 513 |
default () |
| 514 |
$ hg cat a |
| 515 |
neither |
| 516 |
|
| 517 |
$ cd .. |
| 518 |
$ hg init merge-without-evolution |
| 519 |
$ cd merge-without-evolution |
| 520 |
$ mklozenge |
| 521 |
$ cat > .hg/hgrc << EOF |
| 522 |
> [experimental] |
| 523 |
> evolution = no |
| 524 |
> evolution.allowunstable = no |
| 525 |
> EOF |
| 526 |
|
| 527 |
$ hg branch -r '(.^)::' abc |
| 528 |
changed branch on 2 changesets |
| 529 |
saved backup bundle to $TESTTMP/merge-without-evolution/.hg/strip-backup/9a3a2af368f4-8db1a361-branch-change.hg |
| 530 |
$ hg glog |
| 531 |
@ 3:c07fa8b34d54 neither |
| 532 |
|\ abc () |
| 533 |
| o 2:f2aa51777cc9 baz |
| 534 |
| | abc () |
| 535 |
o | 1:2e33c4f0856b bar |
| 536 |
|/ default () |
| 537 |
o 0:91cfb6004abf foo |
| 538 |
default () |
| 539 |
$ hg cat a |
| 540 |
neither |