| 1 |
|
| 2 |
$ hg init repo |
| 3 |
$ cd repo |
| 4 |
|
| 5 |
$ cat > $TESTTMP/hook.sh <<'EOF' |
| 6 |
> echo "test-hook-bookmark: $HG_BOOKMARK: $HG_OLDNODE -> $HG_NODE" |
| 7 |
> EOF |
| 8 |
$ TESTHOOK="hooks.txnclose-bookmark.test=sh $TESTTMP/hook.sh" |
| 9 |
|
| 10 |
no bookmarks |
| 11 |
|
| 12 |
$ hg bookmarks |
| 13 |
no bookmarks set |
| 14 |
|
| 15 |
$ hg bookmarks -Tjson |
| 16 |
[ |
| 17 |
] |
| 18 |
|
| 19 |
bookmark rev -1 |
| 20 |
|
| 21 |
$ hg bookmark X --config "$TESTHOOK" |
| 22 |
test-hook-bookmark: X: -> 0000000000000000000000000000000000000000 |
| 23 |
|
| 24 |
list bookmarks |
| 25 |
|
| 26 |
$ hg bookmarks |
| 27 |
* X -1:000000000000 |
| 28 |
|
| 29 |
list bookmarks with color |
| 30 |
|
| 31 |
$ hg --config extensions.color= --config color.mode=ansi \ |
| 32 |
> bookmarks --color=always |
| 33 |
\x1b[0;32m * \x1b[0m\x1b[0;32mX\x1b[0m\x1b[0;32m -1:000000000000\x1b[0m (esc) |
| 34 |
|
| 35 |
$ echo a > a |
| 36 |
$ hg add a |
| 37 |
$ hg commit -m 0 --config "$TESTHOOK" |
| 38 |
test-hook-bookmark: X: 0000000000000000000000000000000000000000 -> f7b1eb17ad24730a1651fccd46c43826d1bbc2ac |
| 39 |
|
| 40 |
bookmark X moved to rev 0 |
| 41 |
|
| 42 |
$ hg bookmarks |
| 43 |
* X 0:f7b1eb17ad24 |
| 44 |
|
| 45 |
look up bookmark |
| 46 |
|
| 47 |
$ hg log -r X |
| 48 |
changeset: 0:f7b1eb17ad24 |
| 49 |
bookmark: X |
| 50 |
tag: tip |
| 51 |
user: test |
| 52 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 53 |
summary: 0 |
| 54 |
|
| 55 |
|
| 56 |
second bookmark for rev 0, command should work even with ui.strict on |
| 57 |
|
| 58 |
$ hg --config ui.strict=1 bookmark X2 --config "$TESTHOOK" |
| 59 |
test-hook-bookmark: X2: -> f7b1eb17ad24730a1651fccd46c43826d1bbc2ac |
| 60 |
|
| 61 |
bookmark rev -1 again |
| 62 |
|
| 63 |
$ hg bookmark -r null Y |
| 64 |
|
| 65 |
list bookmarks |
| 66 |
|
| 67 |
$ hg bookmarks |
| 68 |
X 0:f7b1eb17ad24 |
| 69 |
* X2 0:f7b1eb17ad24 |
| 70 |
Y -1:000000000000 |
| 71 |
$ hg bookmarks -l |
| 72 |
X 0:f7b1eb17ad24 |
| 73 |
* X2 0:f7b1eb17ad24 |
| 74 |
Y -1:000000000000 |
| 75 |
$ hg bookmarks -l X Y |
| 76 |
X 0:f7b1eb17ad24 |
| 77 |
Y -1:000000000000 |
| 78 |
$ hg bookmarks -l . |
| 79 |
* X2 0:f7b1eb17ad24 |
| 80 |
$ hg bookmarks -l X A Y |
| 81 |
abort: bookmark 'A' does not exist |
| 82 |
[10] |
| 83 |
$ hg bookmarks -l -r0 |
| 84 |
abort: cannot specify both --list and --rev |
| 85 |
[10] |
| 86 |
$ hg bookmarks -l --inactive |
| 87 |
abort: cannot specify both --inactive and --list |
| 88 |
[10] |
| 89 |
|
| 90 |
$ hg log -T '{bookmarks % "{rev} {bookmark}\n"}' |
| 91 |
0 X |
| 92 |
0 X2 |
| 93 |
|
| 94 |
$ echo b > b |
| 95 |
$ hg add b |
| 96 |
$ hg commit -m 1 --config "$TESTHOOK" |
| 97 |
test-hook-bookmark: X2: f7b1eb17ad24730a1651fccd46c43826d1bbc2ac -> 925d80f479bb026b0fb3deb27503780b13f74123 |
| 98 |
|
| 99 |
$ hg bookmarks -T '{rev}:{node|shortest} {bookmark} {desc|firstline}\n' |
| 100 |
0:f7b1 X 0 |
| 101 |
1:925d X2 1 |
| 102 |
-1:0000 Y |
| 103 |
|
| 104 |
$ hg bookmarks -Tjson |
| 105 |
[ |
| 106 |
{ |
| 107 |
"active": false, |
| 108 |
"bookmark": "X", |
| 109 |
"node": "f7b1eb17ad24730a1651fccd46c43826d1bbc2ac", |
| 110 |
"rev": 0 |
| 111 |
}, |
| 112 |
{ |
| 113 |
"active": true, |
| 114 |
"bookmark": "X2", |
| 115 |
"node": "925d80f479bb026b0fb3deb27503780b13f74123", |
| 116 |
"rev": 1 |
| 117 |
}, |
| 118 |
{ |
| 119 |
"active": false, |
| 120 |
"bookmark": "Y", |
| 121 |
"node": "0000000000000000000000000000000000000000", |
| 122 |
"rev": -1 |
| 123 |
} |
| 124 |
] |
| 125 |
|
| 126 |
bookmarks revset |
| 127 |
|
| 128 |
$ hg log -r 'bookmark()' |
| 129 |
changeset: 0:f7b1eb17ad24 |
| 130 |
bookmark: X |
| 131 |
user: test |
| 132 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 133 |
summary: 0 |
| 134 |
|
| 135 |
changeset: 1:925d80f479bb |
| 136 |
bookmark: X2 |
| 137 |
tag: tip |
| 138 |
user: test |
| 139 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 140 |
summary: 1 |
| 141 |
|
| 142 |
$ hg log -r 'bookmark(Y)' |
| 143 |
$ hg log -r 'bookmark(X2)' |
| 144 |
changeset: 1:925d80f479bb |
| 145 |
bookmark: X2 |
| 146 |
tag: tip |
| 147 |
user: test |
| 148 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 149 |
summary: 1 |
| 150 |
|
| 151 |
$ hg log -r 'bookmark("re:X")' |
| 152 |
changeset: 0:f7b1eb17ad24 |
| 153 |
bookmark: X |
| 154 |
user: test |
| 155 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 156 |
summary: 0 |
| 157 |
|
| 158 |
changeset: 1:925d80f479bb |
| 159 |
bookmark: X2 |
| 160 |
tag: tip |
| 161 |
user: test |
| 162 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 163 |
summary: 1 |
| 164 |
|
| 165 |
$ hg log -r 'bookmark("literal:X")' |
| 166 |
changeset: 0:f7b1eb17ad24 |
| 167 |
bookmark: X |
| 168 |
user: test |
| 169 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 170 |
summary: 0 |
| 171 |
|
| 172 |
|
| 173 |
"." is expanded to the active bookmark: |
| 174 |
|
| 175 |
$ hg log -r 'bookmark(.)' |
| 176 |
changeset: 1:925d80f479bb |
| 177 |
bookmark: X2 |
| 178 |
tag: tip |
| 179 |
user: test |
| 180 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 181 |
summary: 1 |
| 182 |
|
| 183 |
|
| 184 |
but "literal:." is not since "." seems not a literal bookmark: |
| 185 |
|
| 186 |
$ hg log -r 'bookmark("literal:.")' |
| 187 |
abort: bookmark '.' does not exist |
| 188 |
[10] |
| 189 |
|
| 190 |
"." should fail if there's no active bookmark: |
| 191 |
|
| 192 |
$ hg bookmark --inactive |
| 193 |
$ hg log -r 'bookmark(.)' |
| 194 |
abort: no active bookmark |
| 195 |
[10] |
| 196 |
$ hg log -r 'present(bookmark(.))' |
| 197 |
|
| 198 |
$ hg log -r 'bookmark(unknown)' |
| 199 |
abort: bookmark 'unknown' does not exist |
| 200 |
[10] |
| 201 |
$ hg log -r 'bookmark("literal:unknown")' |
| 202 |
abort: bookmark 'unknown' does not exist |
| 203 |
[10] |
| 204 |
$ hg log -r 'bookmark("re:unknown")' |
| 205 |
$ hg log -r 'present(bookmark("literal:unknown"))' |
| 206 |
$ hg log -r 'present(bookmark("re:unknown"))' |
| 207 |
|
| 208 |
$ hg help revsets | grep 'bookmark(' |
| 209 |
"bookmark([name])" |
| 210 |
|
| 211 |
reactivate "X2" |
| 212 |
|
| 213 |
$ hg update X2 |
| 214 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 215 |
(activating bookmark X2) |
| 216 |
|
| 217 |
bookmarks X and X2 moved to rev 1, Y at rev -1 |
| 218 |
|
| 219 |
$ hg bookmarks |
| 220 |
X 0:f7b1eb17ad24 |
| 221 |
* X2 1:925d80f479bb |
| 222 |
Y -1:000000000000 |
| 223 |
|
| 224 |
bookmark rev 0 again |
| 225 |
|
| 226 |
$ hg bookmark -r 0 Z |
| 227 |
|
| 228 |
$ hg update X |
| 229 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 230 |
(activating bookmark X) |
| 231 |
$ echo c > c |
| 232 |
$ hg add c |
| 233 |
$ hg commit -m 2 |
| 234 |
created new head |
| 235 |
|
| 236 |
bookmarks X moved to rev 2, Y at rev -1, Z at rev 0 |
| 237 |
|
| 238 |
$ hg bookmarks |
| 239 |
* X 2:db815d6d32e6 |
| 240 |
X2 1:925d80f479bb |
| 241 |
Y -1:000000000000 |
| 242 |
Z 0:f7b1eb17ad24 |
| 243 |
|
| 244 |
rename nonexistent bookmark |
| 245 |
|
| 246 |
$ hg bookmark -m A B |
| 247 |
abort: bookmark 'A' does not exist |
| 248 |
[10] |
| 249 |
|
| 250 |
rename to existent bookmark |
| 251 |
|
| 252 |
$ hg bookmark -m X Y |
| 253 |
abort: bookmark 'Y' already exists (use -f to force) |
| 254 |
[255] |
| 255 |
|
| 256 |
force rename to existent bookmark |
| 257 |
|
| 258 |
$ hg bookmark -f -m X Y |
| 259 |
|
| 260 |
rename bookmark using . |
| 261 |
|
| 262 |
$ hg book rename-me |
| 263 |
$ hg book -m . renamed --config "$TESTHOOK" |
| 264 |
test-hook-bookmark: rename-me: db815d6d32e69058eadefc8cffbad37675707975 -> |
| 265 |
test-hook-bookmark: renamed: -> db815d6d32e69058eadefc8cffbad37675707975 |
| 266 |
$ hg bookmark |
| 267 |
X2 1:925d80f479bb |
| 268 |
Y 2:db815d6d32e6 |
| 269 |
Z 0:f7b1eb17ad24 |
| 270 |
* renamed 2:db815d6d32e6 |
| 271 |
$ hg up -q Y |
| 272 |
$ hg book -d renamed --config "$TESTHOOK" |
| 273 |
test-hook-bookmark: renamed: db815d6d32e69058eadefc8cffbad37675707975 -> |
| 274 |
|
| 275 |
rename bookmark using . with no active bookmark |
| 276 |
|
| 277 |
$ hg book rename-me |
| 278 |
$ hg book -i rename-me |
| 279 |
$ hg book -m . renamed |
| 280 |
abort: no active bookmark |
| 281 |
[10] |
| 282 |
$ hg up -q Y |
| 283 |
$ hg book -d rename-me |
| 284 |
|
| 285 |
delete bookmark using . |
| 286 |
|
| 287 |
$ hg book delete-me |
| 288 |
$ hg book -d . |
| 289 |
$ hg bookmark |
| 290 |
X2 1:925d80f479bb |
| 291 |
Y 2:db815d6d32e6 |
| 292 |
Z 0:f7b1eb17ad24 |
| 293 |
$ hg up -q Y |
| 294 |
|
| 295 |
delete bookmark using . with no active bookmark |
| 296 |
|
| 297 |
$ hg book delete-me |
| 298 |
$ hg book -i delete-me |
| 299 |
$ hg book -d . |
| 300 |
abort: no active bookmark |
| 301 |
[10] |
| 302 |
$ hg up -q Y |
| 303 |
$ hg book -d delete-me |
| 304 |
|
| 305 |
list bookmarks |
| 306 |
|
| 307 |
$ hg bookmark |
| 308 |
X2 1:925d80f479bb |
| 309 |
* Y 2:db815d6d32e6 |
| 310 |
Z 0:f7b1eb17ad24 |
| 311 |
|
| 312 |
bookmarks from a revset |
| 313 |
$ hg bookmark -r '.^1' REVSET |
| 314 |
$ hg bookmark -r ':tip' TIP |
| 315 |
$ hg up -q TIP |
| 316 |
$ hg bookmarks |
| 317 |
REVSET 0:f7b1eb17ad24 |
| 318 |
* TIP 2:db815d6d32e6 |
| 319 |
X2 1:925d80f479bb |
| 320 |
Y 2:db815d6d32e6 |
| 321 |
Z 0:f7b1eb17ad24 |
| 322 |
|
| 323 |
$ hg bookmark -d REVSET |
| 324 |
$ hg bookmark -d TIP |
| 325 |
|
| 326 |
rename without new name or multiple names |
| 327 |
|
| 328 |
$ hg bookmark -m Y |
| 329 |
abort: new bookmark name required |
| 330 |
[10] |
| 331 |
$ hg bookmark -m Y Y2 Y3 |
| 332 |
abort: only one new bookmark name allowed |
| 333 |
[10] |
| 334 |
|
| 335 |
delete without name |
| 336 |
|
| 337 |
$ hg bookmark -d |
| 338 |
abort: bookmark name required |
| 339 |
[10] |
| 340 |
|
| 341 |
delete nonexistent bookmark |
| 342 |
|
| 343 |
$ hg bookmark -d A |
| 344 |
abort: bookmark 'A' does not exist |
| 345 |
[10] |
| 346 |
|
| 347 |
delete with --inactive |
| 348 |
|
| 349 |
$ hg bookmark -d --inactive Y |
| 350 |
abort: cannot specify both --inactive and --delete |
| 351 |
[10] |
| 352 |
|
| 353 |
bookmark name with spaces should be stripped |
| 354 |
|
| 355 |
$ hg bookmark ' x y ' |
| 356 |
|
| 357 |
list bookmarks |
| 358 |
|
| 359 |
$ hg bookmarks |
| 360 |
X2 1:925d80f479bb |
| 361 |
Y 2:db815d6d32e6 |
| 362 |
Z 0:f7b1eb17ad24 |
| 363 |
* x y 2:db815d6d32e6 |
| 364 |
$ hg log -T '{bookmarks % "{rev} {bookmark}\n"}' |
| 365 |
2 Y |
| 366 |
2 x y |
| 367 |
1 X2 |
| 368 |
0 Z |
| 369 |
|
| 370 |
look up stripped bookmark name |
| 371 |
|
| 372 |
$ hg log -r '"x y"' |
| 373 |
changeset: 2:db815d6d32e6 |
| 374 |
bookmark: Y |
| 375 |
bookmark: x y |
| 376 |
tag: tip |
| 377 |
parent: 0:f7b1eb17ad24 |
| 378 |
user: test |
| 379 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 380 |
summary: 2 |
| 381 |
|
| 382 |
|
| 383 |
reject bookmark name with newline |
| 384 |
|
| 385 |
$ hg bookmark ' |
| 386 |
> ' |
| 387 |
abort: bookmark names cannot consist entirely of whitespace |
| 388 |
[10] |
| 389 |
|
| 390 |
$ hg bookmark -m Z ' |
| 391 |
> ' |
| 392 |
abort: bookmark names cannot consist entirely of whitespace |
| 393 |
[10] |
| 394 |
|
| 395 |
bookmark with reserved name |
| 396 |
|
| 397 |
$ hg bookmark tip |
| 398 |
abort: the name 'tip' is reserved |
| 399 |
[10] |
| 400 |
|
| 401 |
$ hg bookmark . |
| 402 |
abort: the name '.' is reserved |
| 403 |
[10] |
| 404 |
|
| 405 |
$ hg bookmark null |
| 406 |
abort: the name 'null' is reserved |
| 407 |
[10] |
| 408 |
|
| 409 |
|
| 410 |
bookmark with existing name |
| 411 |
|
| 412 |
$ hg bookmark X2 |
| 413 |
abort: bookmark 'X2' already exists (use -f to force) |
| 414 |
[255] |
| 415 |
|
| 416 |
$ hg bookmark -m Y Z |
| 417 |
abort: bookmark 'Z' already exists (use -f to force) |
| 418 |
[255] |
| 419 |
|
| 420 |
bookmark with name of branch |
| 421 |
|
| 422 |
$ hg bookmark default |
| 423 |
abort: a bookmark cannot have the name of an existing branch |
| 424 |
[255] |
| 425 |
|
| 426 |
$ hg bookmark -m Y default |
| 427 |
abort: a bookmark cannot have the name of an existing branch |
| 428 |
[255] |
| 429 |
|
| 430 |
bookmark with integer name |
| 431 |
|
| 432 |
$ hg bookmark 10 |
| 433 |
abort: cannot use an integer as a name |
| 434 |
[10] |
| 435 |
|
| 436 |
bookmark with a name that matches a node id |
| 437 |
$ hg bookmark 925d80f479bb db815d6d32e6 --config "$TESTHOOK" |
| 438 |
bookmark 925d80f479bb matches a changeset hash |
| 439 |
(did you leave a -r out of an 'hg bookmark' command?) |
| 440 |
bookmark db815d6d32e6 matches a changeset hash |
| 441 |
(did you leave a -r out of an 'hg bookmark' command?) |
| 442 |
test-hook-bookmark: 925d80f479bb: -> db815d6d32e69058eadefc8cffbad37675707975 |
| 443 |
test-hook-bookmark: db815d6d32e6: -> db815d6d32e69058eadefc8cffbad37675707975 |
| 444 |
$ hg bookmark -d 925d80f479bb |
| 445 |
$ hg bookmark -d db815d6d32e6 |
| 446 |
|
| 447 |
$ cd .. |
| 448 |
|
| 449 |
bookmark with a name that matches an ambiguous node id |
| 450 |
|
| 451 |
$ hg init ambiguous |
| 452 |
$ cd ambiguous |
| 453 |
$ echo 0 > a |
| 454 |
$ hg ci -qAm 0 |
| 455 |
$ for i in 1057 2857 4025; do |
| 456 |
> hg up -q 0 |
| 457 |
> echo $i > a |
| 458 |
> hg ci -qm $i |
| 459 |
> done |
| 460 |
$ hg up -q null |
| 461 |
$ hg log -r0: -T '{rev}:{node}\n' |
| 462 |
0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a |
| 463 |
1:c56256a09cd28e5764f32e8e2810d0f01e2e357a |
| 464 |
2:c5623987d205cd6d9d8389bfc40fff9dbb670b48 |
| 465 |
3:c562ddd9c94164376c20b86b0b4991636a3bf84f |
| 466 |
|
| 467 |
$ hg bookmark -r0 c562 |
| 468 |
$ hg bookmarks |
| 469 |
c562 0:b4e73ffab476 |
| 470 |
|
| 471 |
$ cd .. |
| 472 |
|
| 473 |
incompatible options |
| 474 |
|
| 475 |
$ cd repo |
| 476 |
|
| 477 |
$ hg bookmark -m Y -d Z |
| 478 |
abort: cannot specify both --delete and --rename |
| 479 |
[10] |
| 480 |
|
| 481 |
$ hg bookmark -r 1 -d Z |
| 482 |
abort: cannot specify both --delete and --rev |
| 483 |
[10] |
| 484 |
|
| 485 |
$ hg bookmark -r 1 -m Z Y |
| 486 |
abort: cannot specify both --rename and --rev |
| 487 |
[10] |
| 488 |
|
| 489 |
force bookmark with existing name |
| 490 |
|
| 491 |
$ hg bookmark -f X2 --config "$TESTHOOK" |
| 492 |
test-hook-bookmark: X2: 925d80f479bb026b0fb3deb27503780b13f74123 -> db815d6d32e69058eadefc8cffbad37675707975 |
| 493 |
|
| 494 |
force bookmark back to where it was, should deactivate it |
| 495 |
|
| 496 |
$ hg bookmark -fr1 X2 |
| 497 |
$ hg bookmarks |
| 498 |
X2 1:925d80f479bb |
| 499 |
Y 2:db815d6d32e6 |
| 500 |
Z 0:f7b1eb17ad24 |
| 501 |
x y 2:db815d6d32e6 |
| 502 |
|
| 503 |
forward bookmark to descendant without --force |
| 504 |
|
| 505 |
$ hg bookmark Z |
| 506 |
moving bookmark 'Z' forward from f7b1eb17ad24 |
| 507 |
|
| 508 |
list bookmarks |
| 509 |
|
| 510 |
$ hg bookmark |
| 511 |
X2 1:925d80f479bb |
| 512 |
Y 2:db815d6d32e6 |
| 513 |
* Z 2:db815d6d32e6 |
| 514 |
x y 2:db815d6d32e6 |
| 515 |
$ hg log -T '{bookmarks % "{rev} {bookmark}\n"}' |
| 516 |
2 Y |
| 517 |
2 Z |
| 518 |
2 x y |
| 519 |
1 X2 |
| 520 |
|
| 521 |
revision but no bookmark name |
| 522 |
|
| 523 |
$ hg bookmark -r . |
| 524 |
abort: bookmark name required |
| 525 |
[10] |
| 526 |
|
| 527 |
bookmark name with whitespace only |
| 528 |
|
| 529 |
$ hg bookmark ' ' |
| 530 |
abort: bookmark names cannot consist entirely of whitespace |
| 531 |
[10] |
| 532 |
|
| 533 |
$ hg bookmark -m Y ' ' |
| 534 |
abort: bookmark names cannot consist entirely of whitespace |
| 535 |
[10] |
| 536 |
|
| 537 |
invalid bookmark |
| 538 |
|
| 539 |
$ hg bookmark 'foo:bar' |
| 540 |
abort: ':' cannot be used in a name |
| 541 |
[10] |
| 542 |
|
| 543 |
$ hg bookmark 'foo |
| 544 |
> bar' |
| 545 |
abort: '\n' cannot be used in a name |
| 546 |
[10] |
| 547 |
|
| 548 |
the bookmark extension should be ignored now that it is part of core |
| 549 |
|
| 550 |
$ echo "[extensions]" >> $HGRCPATH |
| 551 |
$ echo "bookmarks=" >> $HGRCPATH |
| 552 |
$ hg bookmarks |
| 553 |
X2 1:925d80f479bb |
| 554 |
Y 2:db815d6d32e6 |
| 555 |
* Z 2:db815d6d32e6 |
| 556 |
x y 2:db815d6d32e6 |
| 557 |
|
| 558 |
test summary |
| 559 |
|
| 560 |
$ hg summary |
| 561 |
parent: 2:db815d6d32e6 tip |
| 562 |
2 |
| 563 |
branch: default |
| 564 |
bookmarks: *Z Y x y |
| 565 |
commit: (clean) |
| 566 |
update: 1 new changesets, 2 branch heads (merge) |
| 567 |
phases: 3 draft |
| 568 |
|
| 569 |
test id |
| 570 |
|
| 571 |
$ hg id |
| 572 |
db815d6d32e6 tip Y/Z/x y |
| 573 |
|
| 574 |
test rollback |
| 575 |
|
| 576 |
$ echo foo > f1 |
| 577 |
$ hg bookmark tmp-rollback |
| 578 |
$ hg add . |
| 579 |
adding f1 |
| 580 |
$ hg ci -mr |
| 581 |
$ hg bookmarks |
| 582 |
X2 1:925d80f479bb |
| 583 |
Y 2:db815d6d32e6 |
| 584 |
Z 2:db815d6d32e6 |
| 585 |
* tmp-rollback 3:2bf5cfec5864 |
| 586 |
x y 2:db815d6d32e6 |
| 587 |
$ hg rollback |
| 588 |
repository tip rolled back to revision 2 (undo commit) |
| 589 |
working directory now based on revision 2 |
| 590 |
$ hg bookmarks |
| 591 |
X2 1:925d80f479bb |
| 592 |
Y 2:db815d6d32e6 |
| 593 |
Z 2:db815d6d32e6 |
| 594 |
* tmp-rollback 2:db815d6d32e6 |
| 595 |
x y 2:db815d6d32e6 |
| 596 |
$ hg bookmark -f Z -r 1 |
| 597 |
$ hg rollback |
| 598 |
repository tip rolled back to revision 2 (undo bookmark) |
| 599 |
$ hg bookmarks |
| 600 |
X2 1:925d80f479bb |
| 601 |
Y 2:db815d6d32e6 |
| 602 |
Z 2:db815d6d32e6 |
| 603 |
* tmp-rollback 2:db815d6d32e6 |
| 604 |
x y 2:db815d6d32e6 |
| 605 |
$ hg bookmark -d tmp-rollback |
| 606 |
|
| 607 |
activate bookmark on working dir parent without --force |
| 608 |
|
| 609 |
$ hg bookmark --inactive Z |
| 610 |
$ hg bookmark Z |
| 611 |
|
| 612 |
deactivate current 'Z', but also add 'Y' |
| 613 |
|
| 614 |
$ hg bookmark -d Y |
| 615 |
$ hg bookmark --inactive Z Y |
| 616 |
$ hg bookmark -l |
| 617 |
X2 1:925d80f479bb |
| 618 |
Y 2:db815d6d32e6 |
| 619 |
Z 2:db815d6d32e6 |
| 620 |
x y 2:db815d6d32e6 |
| 621 |
$ hg bookmark Z |
| 622 |
|
| 623 |
bookmark wdir to activate it (issue6218) |
| 624 |
|
| 625 |
$ hg bookmark -d Z |
| 626 |
$ hg bookmark -r 'wdir()' Z |
| 627 |
$ hg bookmark -l |
| 628 |
X2 1:925d80f479bb |
| 629 |
Y 2:db815d6d32e6 |
| 630 |
* Z 2:db815d6d32e6 |
| 631 |
x y 2:db815d6d32e6 |
| 632 |
|
| 633 |
test clone |
| 634 |
|
| 635 |
$ hg bookmark -r 2 -i @ |
| 636 |
$ hg bookmark -r 2 -i a@ |
| 637 |
$ hg bookmarks |
| 638 |
@ 2:db815d6d32e6 |
| 639 |
X2 1:925d80f479bb |
| 640 |
Y 2:db815d6d32e6 |
| 641 |
* Z 2:db815d6d32e6 |
| 642 |
a@ 2:db815d6d32e6 |
| 643 |
x y 2:db815d6d32e6 |
| 644 |
$ hg clone . cloned-bookmarks |
| 645 |
updating to bookmark @ |
| 646 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 647 |
$ hg -R cloned-bookmarks bookmarks |
| 648 |
* @ 2:db815d6d32e6 |
| 649 |
X2 1:925d80f479bb |
| 650 |
Y 2:db815d6d32e6 |
| 651 |
Z 2:db815d6d32e6 |
| 652 |
a@ 2:db815d6d32e6 |
| 653 |
x y 2:db815d6d32e6 |
| 654 |
|
| 655 |
test clone with pull protocol |
| 656 |
|
| 657 |
$ hg clone --pull . cloned-bookmarks-pull |
| 658 |
requesting all changes |
| 659 |
adding changesets |
| 660 |
adding manifests |
| 661 |
adding file changes |
| 662 |
added 3 changesets with 3 changes to 3 files (+1 heads) |
| 663 |
new changesets f7b1eb17ad24:db815d6d32e6 |
| 664 |
updating to bookmark @ |
| 665 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 666 |
$ hg -R cloned-bookmarks-pull bookmarks |
| 667 |
* @ 2:db815d6d32e6 |
| 668 |
X2 1:925d80f479bb |
| 669 |
Y 2:db815d6d32e6 |
| 670 |
Z 2:db815d6d32e6 |
| 671 |
a@ 2:db815d6d32e6 |
| 672 |
x y 2:db815d6d32e6 |
| 673 |
|
| 674 |
delete multiple bookmarks at once |
| 675 |
|
| 676 |
$ hg bookmark -d @ a@ |
| 677 |
|
| 678 |
test clone with a bookmark named "default" (issue3677) |
| 679 |
|
| 680 |
$ hg bookmark -r 1 -f -i default |
| 681 |
$ hg clone . cloned-bookmark-default |
| 682 |
updating to branch default |
| 683 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 684 |
$ hg -R cloned-bookmark-default bookmarks |
| 685 |
X2 1:925d80f479bb |
| 686 |
Y 2:db815d6d32e6 |
| 687 |
Z 2:db815d6d32e6 |
| 688 |
default 1:925d80f479bb |
| 689 |
x y 2:db815d6d32e6 |
| 690 |
$ hg -R cloned-bookmark-default parents -q |
| 691 |
2:db815d6d32e6 |
| 692 |
$ hg bookmark -d default |
| 693 |
|
| 694 |
test clone with a specific revision |
| 695 |
|
| 696 |
$ hg clone -r 925d80 . cloned-bookmarks-rev |
| 697 |
adding changesets |
| 698 |
adding manifests |
| 699 |
adding file changes |
| 700 |
added 2 changesets with 2 changes to 2 files |
| 701 |
new changesets f7b1eb17ad24:925d80f479bb |
| 702 |
updating to branch default |
| 703 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 704 |
$ hg -R cloned-bookmarks-rev bookmarks |
| 705 |
X2 1:925d80f479bb |
| 706 |
|
| 707 |
test clone with update to a bookmark |
| 708 |
|
| 709 |
$ hg clone -u Z . ../cloned-bookmarks-update |
| 710 |
updating to branch default |
| 711 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 712 |
$ hg -R ../cloned-bookmarks-update bookmarks |
| 713 |
X2 1:925d80f479bb |
| 714 |
Y 2:db815d6d32e6 |
| 715 |
* Z 2:db815d6d32e6 |
| 716 |
x y 2:db815d6d32e6 |
| 717 |
|
| 718 |
create bundle with two heads |
| 719 |
|
| 720 |
$ hg clone . tobundle |
| 721 |
updating to branch default |
| 722 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 723 |
$ echo x > tobundle/x |
| 724 |
$ hg -R tobundle add tobundle/x |
| 725 |
$ hg -R tobundle commit -m'x' |
| 726 |
$ hg -R tobundle update -r -2 |
| 727 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 728 |
$ echo y > tobundle/y |
| 729 |
$ hg -R tobundle branch test |
| 730 |
marked working directory as branch test |
| 731 |
(branches are permanent and global, did you want a bookmark?) |
| 732 |
$ hg -R tobundle add tobundle/y |
| 733 |
$ hg -R tobundle commit -m'y' |
| 734 |
$ hg -R tobundle bundle tobundle.hg |
| 735 |
searching for changes |
| 736 |
2 changesets found |
| 737 |
$ hg unbundle tobundle.hg |
| 738 |
adding changesets |
| 739 |
adding manifests |
| 740 |
adding file changes |
| 741 |
added 2 changesets with 2 changes to 2 files (+1 heads) |
| 742 |
new changesets 125c9a1d6df6:9ba5f110a0b3 (2 drafts) |
| 743 |
(run 'hg heads' to see heads, 'hg merge' to merge) |
| 744 |
|
| 745 |
update to active bookmark if it's not the parent |
| 746 |
|
| 747 |
(it is known issue that fsmonitor can't handle nested repositories. In |
| 748 |
this test scenario, cloned-bookmark-default and tobundle exist in the |
| 749 |
working directory of current repository) |
| 750 |
|
| 751 |
$ hg summary |
| 752 |
parent: 2:db815d6d32e6 |
| 753 |
2 |
| 754 |
branch: default |
| 755 |
bookmarks: *Z Y x y |
| 756 |
commit: 1 added, 1 unknown (new branch head) (no-fsmonitor !) |
| 757 |
commit: 1 added, * unknown (new branch head) (glob) (fsmonitor !) |
| 758 |
update: 2 new changesets (update) |
| 759 |
phases: 5 draft |
| 760 |
$ hg update |
| 761 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 762 |
updating bookmark Z |
| 763 |
$ hg bookmarks |
| 764 |
X2 1:925d80f479bb |
| 765 |
Y 2:db815d6d32e6 |
| 766 |
* Z 3:125c9a1d6df6 |
| 767 |
x y 2:db815d6d32e6 |
| 768 |
|
| 769 |
pull --update works the same as pull && update |
| 770 |
|
| 771 |
$ hg bookmark -r3 Y |
| 772 |
moving bookmark 'Y' forward from db815d6d32e6 |
| 773 |
$ cp -R ../cloned-bookmarks-update ../cloned-bookmarks-manual-update |
| 774 |
$ cp -R ../cloned-bookmarks-update ../cloned-bookmarks-manual-update-with-divergence |
| 775 |
|
| 776 |
(manual version) |
| 777 |
|
| 778 |
$ hg -R ../cloned-bookmarks-manual-update update Y |
| 779 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 780 |
(activating bookmark Y) |
| 781 |
$ hg -R ../cloned-bookmarks-manual-update pull . |
| 782 |
pulling from . |
| 783 |
searching for changes |
| 784 |
adding changesets |
| 785 |
adding manifests |
| 786 |
adding file changes |
| 787 |
updating bookmark Y |
| 788 |
updating bookmark Z |
| 789 |
added 2 changesets with 2 changes to 2 files (+1 heads) |
| 790 |
new changesets 125c9a1d6df6:9ba5f110a0b3 |
| 791 |
(run 'hg heads' to see heads, 'hg merge' to merge) |
| 792 |
|
| 793 |
(# tests strange but with --date crashing when bookmark have to move) |
| 794 |
|
| 795 |
$ hg -R ../cloned-bookmarks-manual-update update -d 1986 |
| 796 |
abort: revision matching date not found |
| 797 |
[10] |
| 798 |
$ hg -R ../cloned-bookmarks-manual-update update |
| 799 |
updating to active bookmark Y |
| 800 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 801 |
|
| 802 |
(all in one version) |
| 803 |
|
| 804 |
$ hg -R ../cloned-bookmarks-update update Y |
| 805 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 806 |
(activating bookmark Y) |
| 807 |
$ hg -R ../cloned-bookmarks-update pull --update . |
| 808 |
pulling from . |
| 809 |
searching for changes |
| 810 |
adding changesets |
| 811 |
adding manifests |
| 812 |
adding file changes |
| 813 |
updating bookmark Y |
| 814 |
updating bookmark Z |
| 815 |
added 2 changesets with 2 changes to 2 files (+1 heads) |
| 816 |
new changesets 125c9a1d6df6:9ba5f110a0b3 |
| 817 |
updating to active bookmark Y |
| 818 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 819 |
|
| 820 |
We warn about divergent during bare update to the active bookmark |
| 821 |
|
| 822 |
$ hg -R ../cloned-bookmarks-manual-update-with-divergence update Y |
| 823 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 824 |
(activating bookmark Y) |
| 825 |
$ hg -R ../cloned-bookmarks-manual-update-with-divergence bookmarks -r X2 Y@1 |
| 826 |
$ hg -R ../cloned-bookmarks-manual-update-with-divergence bookmarks |
| 827 |
X2 1:925d80f479bb |
| 828 |
* Y 2:db815d6d32e6 |
| 829 |
Y@1 1:925d80f479bb |
| 830 |
Z 2:db815d6d32e6 |
| 831 |
x y 2:db815d6d32e6 |
| 832 |
$ hg -R ../cloned-bookmarks-manual-update-with-divergence pull |
| 833 |
pulling from $TESTTMP/repo |
| 834 |
searching for changes |
| 835 |
adding changesets |
| 836 |
adding manifests |
| 837 |
adding file changes |
| 838 |
updating bookmark Y |
| 839 |
updating bookmark Z |
| 840 |
added 2 changesets with 2 changes to 2 files (+1 heads) |
| 841 |
new changesets 125c9a1d6df6:9ba5f110a0b3 |
| 842 |
(run 'hg heads' to see heads, 'hg merge' to merge) |
| 843 |
$ hg -R ../cloned-bookmarks-manual-update-with-divergence update |
| 844 |
updating to active bookmark Y |
| 845 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 846 |
1 other divergent bookmarks for "Y" |
| 847 |
|
| 848 |
test wrongly formated bookmark |
| 849 |
|
| 850 |
$ echo '' >> .hg/bookmarks |
| 851 |
$ hg bookmarks |
| 852 |
X2 1:925d80f479bb |
| 853 |
Y 3:125c9a1d6df6 |
| 854 |
* Z 3:125c9a1d6df6 |
| 855 |
x y 2:db815d6d32e6 |
| 856 |
$ echo "Ican'thasformatedlines" >> .hg/bookmarks |
| 857 |
$ hg bookmarks |
| 858 |
malformed line in .hg/bookmarks: "Ican'thasformatedlines" |
| 859 |
X2 1:925d80f479bb |
| 860 |
Y 3:125c9a1d6df6 |
| 861 |
* Z 3:125c9a1d6df6 |
| 862 |
x y 2:db815d6d32e6 |
| 863 |
|
| 864 |
test missing revisions |
| 865 |
|
| 866 |
$ echo "925d80f479b925d80f479bc925d80f479bccabab z" > .hg/bookmarks |
| 867 |
$ hg book |
| 868 |
no bookmarks set |
| 869 |
|
| 870 |
test stripping a non-checked-out but bookmarked revision |
| 871 |
|
| 872 |
$ hg log --graph |
| 873 |
o changeset: 4:9ba5f110a0b3 |
| 874 |
| branch: test |
| 875 |
| tag: tip |
| 876 |
| parent: 2:db815d6d32e6 |
| 877 |
| user: test |
| 878 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 879 |
| summary: y |
| 880 |
| |
| 881 |
| @ changeset: 3:125c9a1d6df6 |
| 882 |
|/ user: test |
| 883 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 884 |
| summary: x |
| 885 |
| |
| 886 |
o changeset: 2:db815d6d32e6 |
| 887 |
| parent: 0:f7b1eb17ad24 |
| 888 |
| user: test |
| 889 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 890 |
| summary: 2 |
| 891 |
| |
| 892 |
| o changeset: 1:925d80f479bb |
| 893 |
|/ user: test |
| 894 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 895 |
| summary: 1 |
| 896 |
| |
| 897 |
o changeset: 0:f7b1eb17ad24 |
| 898 |
user: test |
| 899 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 900 |
summary: 0 |
| 901 |
|
| 902 |
$ hg book should-end-on-two |
| 903 |
$ hg co --clean 4 |
| 904 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 905 |
(leaving bookmark should-end-on-two) |
| 906 |
$ hg book four |
| 907 |
$ hg --config extensions.mq= strip 3 |
| 908 |
saved backup bundle to * (glob) |
| 909 |
should-end-on-two should end up pointing to revision 2, as that's the |
| 910 |
tipmost surviving ancestor of the stripped revision. |
| 911 |
$ hg log --graph |
| 912 |
@ changeset: 3:9ba5f110a0b3 |
| 913 |
| branch: test |
| 914 |
| bookmark: four |
| 915 |
| tag: tip |
| 916 |
| user: test |
| 917 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 918 |
| summary: y |
| 919 |
| |
| 920 |
o changeset: 2:db815d6d32e6 |
| 921 |
| bookmark: should-end-on-two |
| 922 |
| parent: 0:f7b1eb17ad24 |
| 923 |
| user: test |
| 924 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 925 |
| summary: 2 |
| 926 |
| |
| 927 |
| o changeset: 1:925d80f479bb |
| 928 |
|/ user: test |
| 929 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 930 |
| summary: 1 |
| 931 |
| |
| 932 |
o changeset: 0:f7b1eb17ad24 |
| 933 |
user: test |
| 934 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 935 |
summary: 0 |
| 936 |
|
| 937 |
|
| 938 |
no-op update doesn't deactivate bookmarks |
| 939 |
|
| 940 |
(it is known issue that fsmonitor can't handle nested repositories. In |
| 941 |
this test scenario, cloned-bookmark-default and tobundle exist in the |
| 942 |
working directory of current repository) |
| 943 |
|
| 944 |
$ hg bookmarks |
| 945 |
* four 3:9ba5f110a0b3 |
| 946 |
should-end-on-two 2:db815d6d32e6 |
| 947 |
$ hg up four |
| 948 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 949 |
$ hg up |
| 950 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 951 |
$ hg sum |
| 952 |
parent: 3:9ba5f110a0b3 tip |
| 953 |
y |
| 954 |
branch: test |
| 955 |
bookmarks: *four |
| 956 |
commit: 2 unknown (clean) (no-fsmonitor !) |
| 957 |
commit: * unknown (clean) (glob) (fsmonitor !) |
| 958 |
update: (current) |
| 959 |
phases: 4 draft |
| 960 |
|
| 961 |
test clearing divergent bookmarks of linear ancestors |
| 962 |
|
| 963 |
$ hg bookmark Z -r 0 |
| 964 |
$ hg bookmark Z@1 -r 1 |
| 965 |
$ hg bookmark Z@2 -r 2 |
| 966 |
$ hg bookmark Z@3 -r 3 |
| 967 |
$ hg book |
| 968 |
Z 0:f7b1eb17ad24 |
| 969 |
Z@1 1:925d80f479bb |
| 970 |
Z@2 2:db815d6d32e6 |
| 971 |
Z@3 3:9ba5f110a0b3 |
| 972 |
* four 3:9ba5f110a0b3 |
| 973 |
should-end-on-two 2:db815d6d32e6 |
| 974 |
$ hg bookmark Z |
| 975 |
moving bookmark 'Z' forward from f7b1eb17ad24 |
| 976 |
$ hg book |
| 977 |
* Z 3:9ba5f110a0b3 |
| 978 |
Z@1 1:925d80f479bb |
| 979 |
four 3:9ba5f110a0b3 |
| 980 |
should-end-on-two 2:db815d6d32e6 |
| 981 |
|
| 982 |
test clearing only a single divergent bookmark across branches |
| 983 |
|
| 984 |
$ hg book foo -r 1 |
| 985 |
$ hg book foo@1 -r 0 |
| 986 |
$ hg book foo@2 -r 2 |
| 987 |
$ hg book foo@3 -r 3 |
| 988 |
$ hg book foo -r foo@3 |
| 989 |
$ hg book |
| 990 |
* Z 3:9ba5f110a0b3 |
| 991 |
Z@1 1:925d80f479bb |
| 992 |
foo 3:9ba5f110a0b3 |
| 993 |
foo@1 0:f7b1eb17ad24 |
| 994 |
foo@2 2:db815d6d32e6 |
| 995 |
four 3:9ba5f110a0b3 |
| 996 |
should-end-on-two 2:db815d6d32e6 |
| 997 |
|
| 998 |
pull --update works the same as pull && update (case #2) |
| 999 |
|
| 1000 |
It is assumed that "hg pull" itself doesn't update current active |
| 1001 |
bookmark ('Y' in tests below). |
| 1002 |
|
| 1003 |
$ hg pull -q ../cloned-bookmarks-update |
| 1004 |
divergent bookmark Z stored as Z@2 |
| 1005 |
|
| 1006 |
(pulling revision on another named branch with --update updates |
| 1007 |
neither the working directory nor current active bookmark: "no-op" |
| 1008 |
case) |
| 1009 |
|
| 1010 |
$ echo yy >> y |
| 1011 |
$ hg commit -m yy |
| 1012 |
|
| 1013 |
$ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' |
| 1014 |
* Y 3:125c9a1d6df6 |
| 1015 |
$ hg -R ../cloned-bookmarks-update path |
| 1016 |
default = $TESTTMP/repo |
| 1017 |
$ pwd |
| 1018 |
$TESTTMP/repo |
| 1019 |
$ hg -R ../cloned-bookmarks-update pull . --update |
| 1020 |
pulling from . |
| 1021 |
searching for changes |
| 1022 |
adding changesets |
| 1023 |
adding manifests |
| 1024 |
adding file changes |
| 1025 |
divergent bookmark Z stored as Z@default |
| 1026 |
adding remote bookmark foo |
| 1027 |
adding remote bookmark four |
| 1028 |
adding remote bookmark should-end-on-two |
| 1029 |
added 1 changesets with 1 changes to 1 files |
| 1030 |
new changesets 5fb12f0f2d51 |
| 1031 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 1032 |
$ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n" |
| 1033 |
3:125c9a1d6df6 |
| 1034 |
$ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' |
| 1035 |
* Y 3:125c9a1d6df6 |
| 1036 |
|
| 1037 |
(pulling revision on current named/topological branch with --update |
| 1038 |
updates the working directory and current active bookmark) |
| 1039 |
|
| 1040 |
$ hg update -C -q 125c9a1d6df6 |
| 1041 |
$ echo xx >> x |
| 1042 |
$ hg commit -m xx |
| 1043 |
|
| 1044 |
$ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' |
| 1045 |
* Y 3:125c9a1d6df6 |
| 1046 |
$ hg -R ../cloned-bookmarks-update pull . --update |
| 1047 |
pulling from . |
| 1048 |
searching for changes |
| 1049 |
adding changesets |
| 1050 |
adding manifests |
| 1051 |
adding file changes |
| 1052 |
divergent bookmark Z stored as Z@default |
| 1053 |
added 1 changesets with 1 changes to 1 files |
| 1054 |
new changesets 81dcce76aa0b |
| 1055 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 1056 |
updating bookmark Y |
| 1057 |
$ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n" |
| 1058 |
6:81dcce76aa0b |
| 1059 |
$ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' |
| 1060 |
* Y 6:81dcce76aa0b |
| 1061 |
|
| 1062 |
$ cd .. |
| 1063 |
|
| 1064 |
ensure changelog is written before bookmarks |
| 1065 |
$ hg init orderrepo |
| 1066 |
$ cd orderrepo |
| 1067 |
$ touch a |
| 1068 |
$ hg commit -Aqm one |
| 1069 |
$ hg book mybook |
| 1070 |
$ echo a > a |
| 1071 |
|
| 1072 |
$ cat > $TESTTMP/pausefinalize.py <<EOF |
| 1073 |
> import os |
| 1074 |
> import time |
| 1075 |
> from mercurial import extensions, localrepo |
| 1076 |
> def transaction(orig, self, desc, report=None): |
| 1077 |
> tr = orig(self, desc, report) |
| 1078 |
> def sleep(*args, **kwargs): |
| 1079 |
> retry = 20 |
| 1080 |
> while retry > 0 and not os.path.exists(b"$TESTTMP/unpause"): |
| 1081 |
> retry -= 1 |
| 1082 |
> time.sleep(0.5) |
| 1083 |
> if os.path.exists(b"$TESTTMP/unpause"): |
| 1084 |
> os.remove(b"$TESTTMP/unpause") |
| 1085 |
> # It is important that this finalizer start with '000-a', so it runs |
| 1086 |
> # before the changelog finalizer appends to the changelog. |
| 1087 |
> tr.addfinalize(b'000-a-sleep', sleep) |
| 1088 |
> return tr |
| 1089 |
> |
| 1090 |
> def extsetup(ui): |
| 1091 |
> # This extension inserts an artifical pause during the transaction |
| 1092 |
> # finalizer, so we can run commands mid-transaction-close. |
| 1093 |
> extensions.wrapfunction(localrepo.localrepository, 'transaction', |
| 1094 |
> transaction) |
| 1095 |
> EOF |
| 1096 |
$ hg commit -qm two --config extensions.pausefinalize=$TESTTMP/pausefinalize.py & |
| 1097 |
$ sleep 2 |
| 1098 |
$ hg log -r . |
| 1099 |
changeset: 0:867bc5792c8c |
| 1100 |
bookmark: mybook |
| 1101 |
tag: tip |
| 1102 |
user: test |
| 1103 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 1104 |
summary: one |
| 1105 |
|
| 1106 |
$ hg bookmarks |
| 1107 |
* mybook 0:867bc5792c8c |
| 1108 |
$ touch $TESTTMP/unpause |
| 1109 |
|
| 1110 |
$ cd .. |
| 1111 |
|
| 1112 |
check whether HG_PENDING makes pending changes only in related |
| 1113 |
repositories visible to an external hook. |
| 1114 |
|
| 1115 |
(emulate a transaction running concurrently by copied |
| 1116 |
.hg/bookmarks.pending in subsequent test) |
| 1117 |
|
| 1118 |
$ cat > $TESTTMP/savepending.sh <<EOF |
| 1119 |
> cp .hg/bookmarks.pending .hg/bookmarks.pending.saved |
| 1120 |
> exit 1 # to avoid adding new bookmark for subsequent tests |
| 1121 |
> EOF |
| 1122 |
|
| 1123 |
$ hg init unrelated |
| 1124 |
$ cd unrelated |
| 1125 |
$ echo a > a |
| 1126 |
$ hg add a |
| 1127 |
$ hg commit -m '#0' |
| 1128 |
$ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" bookmarks INVISIBLE |
| 1129 |
abort: pretxnclose hook exited with status 1 |
| 1130 |
[40] |
| 1131 |
$ cp .hg/bookmarks.pending.saved .hg/bookmarks.pending |
| 1132 |
|
| 1133 |
(check visible bookmarks while transaction running in repo) |
| 1134 |
|
| 1135 |
$ cat > $TESTTMP/checkpending.sh <<EOF |
| 1136 |
> echo "@repo" |
| 1137 |
> hg -R "$TESTTMP/repo" bookmarks |
| 1138 |
> echo "@unrelated" |
| 1139 |
> hg -R "$TESTTMP/unrelated" bookmarks |
| 1140 |
> exit 1 # to avoid adding new bookmark for subsequent tests |
| 1141 |
> EOF |
| 1142 |
|
| 1143 |
$ cd ../repo |
| 1144 |
$ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" bookmarks NEW |
| 1145 |
@repo |
| 1146 |
* NEW 6:81dcce76aa0b |
| 1147 |
X2 1:925d80f479bb |
| 1148 |
Y 4:125c9a1d6df6 |
| 1149 |
Z 5:5fb12f0f2d51 |
| 1150 |
Z@1 1:925d80f479bb |
| 1151 |
Z@2 4:125c9a1d6df6 |
| 1152 |
foo 3:9ba5f110a0b3 |
| 1153 |
foo@1 0:f7b1eb17ad24 |
| 1154 |
foo@2 2:db815d6d32e6 |
| 1155 |
four 3:9ba5f110a0b3 |
| 1156 |
should-end-on-two 2:db815d6d32e6 |
| 1157 |
x y 2:db815d6d32e6 |
| 1158 |
@unrelated |
| 1159 |
no bookmarks set |
| 1160 |
abort: pretxnclose hook exited with status 1 |
| 1161 |
[40] |
| 1162 |
|
| 1163 |
Check pretxnclose-bookmark can abort a transaction |
| 1164 |
-------------------------------------------------- |
| 1165 |
|
| 1166 |
add hooks: |
| 1167 |
|
| 1168 |
* to prevent NEW bookmark on a non-public changeset |
| 1169 |
* to prevent non-forward move of NEW bookmark |
| 1170 |
|
| 1171 |
$ cat << EOF >> .hg/hgrc |
| 1172 |
> [hooks] |
| 1173 |
> pretxnclose-bookmark.force-public = sh -c "(echo \$HG_BOOKMARK| grep -v NEW > /dev/null) || [ -z \"\$HG_NODE\" ] || (hg log -r \"\$HG_NODE\" -T '{phase}' | grep public > /dev/null)" |
| 1174 |
> pretxnclose-bookmark.force-forward = sh -c "(echo \$HG_BOOKMARK| grep -v NEW > /dev/null) || [ -z \"\$HG_NODE\" ] || (hg log -r \"max(\$HG_OLDNODE::\$HG_NODE)\" -T 'MATCH' | grep MATCH > /dev/null)" |
| 1175 |
> EOF |
| 1176 |
|
| 1177 |
$ hg log -G -T phases |
| 1178 |
@ changeset: 6:81dcce76aa0b |
| 1179 |
| tag: tip |
| 1180 |
| phase: draft |
| 1181 |
| parent: 4:125c9a1d6df6 |
| 1182 |
| user: test |
| 1183 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 1184 |
| summary: xx |
| 1185 |
| |
| 1186 |
| o changeset: 5:5fb12f0f2d51 |
| 1187 |
| | branch: test |
| 1188 |
| | bookmark: Z |
| 1189 |
| | phase: draft |
| 1190 |
| | parent: 3:9ba5f110a0b3 |
| 1191 |
| | user: test |
| 1192 |
| | date: Thu Jan 01 00:00:00 1970 +0000 |
| 1193 |
| | summary: yy |
| 1194 |
| | |
| 1195 |
o | changeset: 4:125c9a1d6df6 |
| 1196 |
| | bookmark: Y |
| 1197 |
| | bookmark: Z@2 |
| 1198 |
| | phase: public |
| 1199 |
| | parent: 2:db815d6d32e6 |
| 1200 |
| | user: test |
| 1201 |
| | date: Thu Jan 01 00:00:00 1970 +0000 |
| 1202 |
| | summary: x |
| 1203 |
| | |
| 1204 |
| o changeset: 3:9ba5f110a0b3 |
| 1205 |
|/ branch: test |
| 1206 |
| bookmark: foo |
| 1207 |
| bookmark: four |
| 1208 |
| phase: public |
| 1209 |
| user: test |
| 1210 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 1211 |
| summary: y |
| 1212 |
| |
| 1213 |
o changeset: 2:db815d6d32e6 |
| 1214 |
| bookmark: foo@2 |
| 1215 |
| bookmark: should-end-on-two |
| 1216 |
| bookmark: x y |
| 1217 |
| phase: public |
| 1218 |
| parent: 0:f7b1eb17ad24 |
| 1219 |
| user: test |
| 1220 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 1221 |
| summary: 2 |
| 1222 |
| |
| 1223 |
| o changeset: 1:925d80f479bb |
| 1224 |
|/ bookmark: X2 |
| 1225 |
| bookmark: Z@1 |
| 1226 |
| phase: public |
| 1227 |
| user: test |
| 1228 |
| date: Thu Jan 01 00:00:00 1970 +0000 |
| 1229 |
| summary: 1 |
| 1230 |
| |
| 1231 |
o changeset: 0:f7b1eb17ad24 |
| 1232 |
bookmark: foo@1 |
| 1233 |
phase: public |
| 1234 |
user: test |
| 1235 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 1236 |
summary: 0 |
| 1237 |
|
| 1238 |
|
| 1239 |
attempt to create on a default changeset |
| 1240 |
|
| 1241 |
$ hg bookmark -r 81dcce76aa0b NEW |
| 1242 |
abort: pretxnclose-bookmark.force-public hook exited with status 1 |
| 1243 |
[40] |
| 1244 |
|
| 1245 |
create on a public changeset |
| 1246 |
|
| 1247 |
$ hg bookmark -r 9ba5f110a0b3 NEW |
| 1248 |
|
| 1249 |
move to the other branch |
| 1250 |
|
| 1251 |
$ hg bookmark -f -r 125c9a1d6df6 NEW |
| 1252 |
abort: pretxnclose-bookmark.force-forward hook exited with status 1 |
| 1253 |
[40] |