comparison tests/test-branches.t @ 34074:abf91c4f9608

branches: correctly show inactive multiheaded branches Issue being fixed here: `hg branches` incorrectly renders inactive multiheaded branches as active if they have closed heads. Example: ``` $ hg log --template '{rev}:{node|short} "{desc}" ({branch}) [parents: {parents}]\n' 4:2e2fa7af8357 "merge" (default) [parents: 0:c94e548c8c7d 3:7be622ae5832 ] 3:7be622ae5832 "2" (somebranch) [parents: 1:81c1d9458987 ] 2:be82cf30409c "close" (somebranch) [parents: ] 1:81c1d9458987 "1" (somebranch) [parents: ] 0:c94e548c8c7d "initial" (default) [parents: ] $ hg branches default 4:2e2fa7af8357 somebranch 3:7be622ae5832 ``` Branch `somebranch` have two heads, the 1st one being closed (rev 2) and the other one being merged into default (rev 3). This branch should be shown as inactive one. This happens because we intersect branch heads with repo heads to check branch activity. In this case intersection in a set with one node (rev 2). This head is closed but the branch is marked as active nevertheless. Fix is to check branch activity by intersecting only open heads set. Fixed output: ``` $ hg branches default 4:2e2fa7af8357 somebranch 3:7be622ae5832 (inactive) ``` Relevant tests for multihead branches added to test-branches suite. Implentation note about adding `iteropen` method: At first I have tried to modify `iterbranches` is such a way that it would filter out closed heads itself. For example it could have `closed=False` parameter. But in this case we would have to filter closed tips as well. Reasoning in terms of `hg branches` we actually are not allowed to do this. Also, we need to do heads filtering only if tip is not closed itself. But if it is - we are ok to skip filtering, because branch is already known to be inactive. So we can't implement heads filtering in `iterbranches` in elegant way, because we will end up with something like `closed_heads=False` or even `closed_heads_is_tip_is_open`. Finally I decided to move this logic to the `branches` function, adding `iteropen` helper method. Differential Revision: https://phab.mercurial-scm.org/D583
author the31k <the31k@thethirty.one>
date Thu, 31 Aug 2017 18:24:08 +0300
parents 61b60b28c381
children eb586ed5d8ce
comparison
equal deleted inserted replaced
34073:7bbc4e113e5f 34074:abf91c4f9608
416 branch: b 416 branch: b
417 user: test 417 user: test
418 date: Thu Jan 01 00:00:09 1970 +0000 418 date: Thu Jan 01 00:00:09 1970 +0000
419 summary: prune bad branch 419 summary: prune bad branch
420 420
421
422 reclose branch
423
424 $ hg up -C c
425 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
426 $ hg commit -d '9 0' --close-branch -m 'reclosing this branch'
427 $ hg branches
428 b 13:e23b5505d1ad
429 a branch name much longer than the default justification used by branches 7:10ff5895aa57
430 a 5:d8cbc61dbaa6 (inactive)
431 default 0:19709c5a4e75 (inactive)
432 $ hg branches --closed
433 b 13:e23b5505d1ad
434 a branch name much longer than the default justification used by branches 7:10ff5895aa57
435 c 14:f894c25619d3 (closed)
436 a 5:d8cbc61dbaa6 (inactive)
437 default 0:19709c5a4e75 (inactive)
438
439 multihead branch
440
441 $ hg up -C default
442 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
443 $ hg branch m
444 marked working directory as branch m
445 $ touch m
446 $ hg add m
447 $ hg commit -d '10 0' -m 'multihead base'
448 $ echo "m1" >m
449 $ hg commit -d '10 0' -m 'head 1'
450 $ hg up -C '.^'
451 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
452 $ echo "m2" >m
453 $ hg commit -d '10 0' -m 'head 2'
454 created new head
455 $ hg log -b m
456 changeset: 17:df343b0df04f
457 branch: m
458 tag: tip
459 parent: 15:f3447637f53e
460 user: test
461 date: Thu Jan 01 00:00:10 1970 +0000
462 summary: head 2
463
464 changeset: 16:a58ca5d3bdf3
465 branch: m
466 user: test
467 date: Thu Jan 01 00:00:10 1970 +0000
468 summary: head 1
469
470 changeset: 15:f3447637f53e
471 branch: m
472 parent: 0:19709c5a4e75
473 user: test
474 date: Thu Jan 01 00:00:10 1970 +0000
475 summary: multihead base
476
477 $ hg heads --topo m
478 changeset: 17:df343b0df04f
479 branch: m
480 tag: tip
481 parent: 15:f3447637f53e
482 user: test
483 date: Thu Jan 01 00:00:10 1970 +0000
484 summary: head 2
485
486 changeset: 16:a58ca5d3bdf3
487 branch: m
488 user: test
489 date: Thu Jan 01 00:00:10 1970 +0000
490 summary: head 1
491
492 $ hg branches
493 m 17:df343b0df04f
494 b 13:e23b5505d1ad
495 a branch name much longer than the default justification used by branches 7:10ff5895aa57
496 a 5:d8cbc61dbaa6 (inactive)
497 default 0:19709c5a4e75 (inactive)
498
499 partially merge multihead branch
500
501 $ hg up -C default
502 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
503 $ hg branch md
504 marked working directory as branch md
505 $ hg merge m
506 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
507 (branch merge, don't forget to commit)
508 $ hg commit -d '11 0' -m 'merge head 2'
509 $ hg heads --topo m
510 changeset: 16:a58ca5d3bdf3
511 branch: m
512 user: test
513 date: Thu Jan 01 00:00:10 1970 +0000
514 summary: head 1
515
516 $ hg branches
517 md 18:c914c99f1fbb
518 m 17:df343b0df04f
519 b 13:e23b5505d1ad
520 a branch name much longer than the default justification used by branches 7:10ff5895aa57
521 a 5:d8cbc61dbaa6 (inactive)
522 default 0:19709c5a4e75 (inactive)
523
524 partially close multihead branch
525
526 $ hg up -C a58ca5d3bdf3
527 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
528 $ hg commit -d '12 0' -m 'close head 1' --close-branch
529 $ hg heads --topo m
530 changeset: 19:cd21a80baa3d
531 branch: m
532 tag: tip
533 parent: 16:a58ca5d3bdf3
534 user: test
535 date: Thu Jan 01 00:00:12 1970 +0000
536 summary: close head 1
537
538 $ hg branches
539 md 18:c914c99f1fbb
540 b 13:e23b5505d1ad
541 a branch name much longer than the default justification used by branches 7:10ff5895aa57
542 m 17:df343b0df04f (inactive)
543 a 5:d8cbc61dbaa6 (inactive)
544 default 0:19709c5a4e75 (inactive)
545
421 default branch colors: 546 default branch colors:
422 547
423 $ cat <<EOF >> $HGRCPATH 548 $ cat <<EOF >> $HGRCPATH
424 > [extensions] 549 > [extensions]
425 > color = 550 > color =
426 > [color] 551 > [color]
427 > mode = ansi 552 > mode = ansi
428 > EOF 553 > EOF
429 554
430 $ hg up -C c
431 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
432 $ hg commit -d '9 0' --close-branch -m 'reclosing this branch'
433 $ hg up -C b 555 $ hg up -C b
434 2 files updated, 0 files merged, 3 files removed, 0 files unresolved 556 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
435 $ hg branches --color=always 557 $ hg branches --color=always
558 \x1b[0;0mmd\x1b[0m\x1b[0;33m 18:c914c99f1fbb\x1b[0m (esc)
436 \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc) 559 \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc)
437 \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc) 560 \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc)
561 \x1b[0;0mm\x1b[0m\x1b[0;33m 17:df343b0df04f\x1b[0m (inactive) (esc)
438 \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) 562 \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
439 \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc) 563 \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc)
440 564
441 default closed branch color: 565 default closed branch color:
442 566
443 $ hg branches --color=always --closed 567 $ hg branches --color=always --closed
568 \x1b[0;0mmd\x1b[0m\x1b[0;33m 18:c914c99f1fbb\x1b[0m (esc)
444 \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc) 569 \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc)
445 \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc) 570 \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc)
571 \x1b[0;0mm\x1b[0m\x1b[0;33m 17:df343b0df04f\x1b[0m (inactive) (esc)
446 \x1b[0;30;1mc\x1b[0m\x1b[0;33m 14:f894c25619d3\x1b[0m (closed) (esc) 572 \x1b[0;30;1mc\x1b[0m\x1b[0;33m 14:f894c25619d3\x1b[0m (closed) (esc)
447 \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) 573 \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
448 \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc) 574 \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc)
449 575
450 $ cat <<EOF >> $HGRCPATH 576 $ cat <<EOF >> $HGRCPATH
459 > EOF 585 > EOF
460 586
461 custom branch colors: 587 custom branch colors:
462 588
463 $ hg branches --color=always 589 $ hg branches --color=always
590 \x1b[0;32mmd\x1b[0m\x1b[0;36m 18:c914c99f1fbb\x1b[0m (esc)
464 \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc) 591 \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc)
465 \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc) 592 \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc)
593 \x1b[0;35mm\x1b[0m\x1b[0;36m 17:df343b0df04f\x1b[0m (inactive) (esc)
466 \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) 594 \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
467 \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc) 595 \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc)
468 596
469 custom closed branch color: 597 custom closed branch color:
470 598
471 $ hg branches --color=always --closed 599 $ hg branches --color=always --closed
600 \x1b[0;32mmd\x1b[0m\x1b[0;36m 18:c914c99f1fbb\x1b[0m (esc)
472 \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc) 601 \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc)
473 \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc) 602 \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc)
603 \x1b[0;35mm\x1b[0m\x1b[0;36m 17:df343b0df04f\x1b[0m (inactive) (esc)
474 \x1b[0;34mc\x1b[0m\x1b[0;36m 14:f894c25619d3\x1b[0m (closed) (esc) 604 \x1b[0;34mc\x1b[0m\x1b[0;36m 14:f894c25619d3\x1b[0m (closed) (esc)
475 \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) 605 \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
476 \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc) 606 \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc)
477 607
478 template output: 608 template output:
479 609
480 $ hg branches -Tjson --closed 610 $ hg branches -Tjson --closed
481 [ 611 [
612 {
613 "active": true,
614 "branch": "md",
615 "closed": false,
616 "current": false,
617 "node": "c914c99f1fbb2b1d785a0a939ed3f67275df18e9",
618 "rev": 18
619 },
482 { 620 {
483 "active": true, 621 "active": true,
484 "branch": "b", 622 "branch": "b",
485 "closed": false, 623 "closed": false,
486 "current": true, 624 "current": true,
492 "branch": "a branch name much longer than the default justification used by branches", 630 "branch": "a branch name much longer than the default justification used by branches",
493 "closed": false, 631 "closed": false,
494 "current": false, 632 "current": false,
495 "node": "10ff5895aa5793bd378da574af8cec8ea408d831", 633 "node": "10ff5895aa5793bd378da574af8cec8ea408d831",
496 "rev": 7 634 "rev": 7
635 },
636 {
637 "active": false,
638 "branch": "m",
639 "closed": false,
640 "current": false,
641 "node": "df343b0df04feb2a946cd4b6e9520e552fef14ee",
642 "rev": 17
497 }, 643 },
498 { 644 {
499 "active": false, 645 "active": false,
500 "branch": "c", 646 "branch": "c",
501 "closed": true, 647 "closed": true,
523 669
524 $ hg branches --closed -T '{if(closed, "{branch}\n")}' 670 $ hg branches --closed -T '{if(closed, "{branch}\n")}'
525 c 671 c
526 672
527 $ hg branches -T '{word(0, branch)}: {desc|firstline}\n' 673 $ hg branches -T '{word(0, branch)}: {desc|firstline}\n'
674 md: merge head 2
528 b: reopen branch with a change 675 b: reopen branch with a change
529 a: Adding d branch 676 a: Adding d branch
677 m: head 2
530 a: Adding b branch head 2 678 a: Adding b branch head 2
531 default: Adding root node 679 default: Adding root node
532 680
533 $ cat <<'EOF' > "$TESTTMP/map-myjson" 681 $ cat <<'EOF' > "$TESTTMP/map-myjson"
534 > docheader = '\{\n' 682 > docheader = '\{\n'
536 > separator = ',\n' 684 > separator = ',\n'
537 > branches = ' {dict(branch, node|short)|json}' 685 > branches = ' {dict(branch, node|short)|json}'
538 > EOF 686 > EOF
539 $ hg branches -T "$TESTTMP/map-myjson" 687 $ hg branches -T "$TESTTMP/map-myjson"
540 { 688 {
689 {"branch": "md", "node": "c914c99f1fbb"},
541 {"branch": "b", "node": "e23b5505d1ad"}, 690 {"branch": "b", "node": "e23b5505d1ad"},
542 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob) 691 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob)
692 {"branch": "m", "node": "df343b0df04f"},
543 {"branch": "a", "node": "d8cbc61dbaa6"}, 693 {"branch": "a", "node": "d8cbc61dbaa6"},
544 {"branch": "default", "node": "19709c5a4e75"} 694 {"branch": "default", "node": "19709c5a4e75"}
545 } 695 }
546 696
547 $ cat <<'EOF' >> .hg/hgrc 697 $ cat <<'EOF' >> .hg/hgrc
551 > myjson:docfooter = '\n}\n' 701 > myjson:docfooter = '\n}\n'
552 > myjson:separator = ',\n' 702 > myjson:separator = ',\n'
553 > EOF 703 > EOF
554 $ hg branches -T myjson 704 $ hg branches -T myjson
555 { 705 {
706 {"branch": "md", "node": "c914c99f1fbb"},
556 {"branch": "b", "node": "e23b5505d1ad"}, 707 {"branch": "b", "node": "e23b5505d1ad"},
557 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob) 708 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob)
709 {"branch": "m", "node": "df343b0df04f"},
558 {"branch": "a", "node": "d8cbc61dbaa6"}, 710 {"branch": "a", "node": "d8cbc61dbaa6"},
559 {"branch": "default", "node": "19709c5a4e75"} 711 {"branch": "default", "node": "19709c5a4e75"}
560 } 712 }
561 713
562 $ cat <<'EOF' >> .hg/hgrc 714 $ cat <<'EOF' >> .hg/hgrc
563 > [templates] 715 > [templates]
564 > :docheader = 'should not be selected as a docheader for literal templates\n' 716 > :docheader = 'should not be selected as a docheader for literal templates\n'
565 > EOF 717 > EOF
566 $ hg branches -T '{branch}\n' 718 $ hg branches -T '{branch}\n'
719 md
567 b 720 b
568 a branch name much longer than the default justification used by branches 721 a branch name much longer than the default justification used by branches
722 m
569 a 723 a
570 default 724 default
571 725
572 Tests of revision branch name caching 726 Tests of revision branch name caching
573 727
577 731
578 revision branch cache is created when building the branch head cache 732 revision branch cache is created when building the branch head cache
579 $ rm -rf .hg/cache; hg head a -T '{rev}\n' 733 $ rm -rf .hg/cache; hg head a -T '{rev}\n'
580 5 734 5
581 $ f --hexdump --size .hg/cache/rbc-* 735 $ f --hexdump --size .hg/cache/rbc-*
582 .hg/cache/rbc-names-v1: size=87 736 .hg/cache/rbc-names-v1: size=92
583 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a | 737 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
584 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much| 738 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
585 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the| 739 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
586 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi| 740 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
587 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b| 741 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
588 0050: 72 61 6e 63 68 65 73 |ranches| 742 0050: 72 61 6e 63 68 65 73 00 6d 00 6d 64 |ranches.m.md|
589 .hg/cache/rbc-revs-v1: size=120 743 .hg/cache/rbc-revs-v1: size=160
590 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| 744 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
591 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....| 745 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
592 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................| 746 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
593 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....| 747 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
594 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....| 748 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
595 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....| 749 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
596 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....| 750 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
597 0070: f8 94 c2 56 80 00 00 03 |...V....| 751 0070: f8 94 c2 56 80 00 00 03 f3 44 76 37 00 00 00 05 |...V.....Dv7....|
752 0080: a5 8c a5 d3 00 00 00 05 df 34 3b 0d 00 00 00 05 |.........4;.....|
753 0090: c9 14 c9 9f 00 00 00 06 cd 21 a8 0b 80 00 00 05 |.........!......|
598 754
599 no errors when revbranchcache is not writable 755 no errors when revbranchcache is not writable
600 756
601 $ echo >> .hg/cache/rbc-revs-v1 757 $ echo >> .hg/cache/rbc-revs-v1
602 $ mv .hg/cache/rbc-revs-v1 .hg/cache/rbc-revs-v1_ 758 $ mv .hg/cache/rbc-revs-v1 .hg/cache/rbc-revs-v1_
620 776
621 recovery from invalid cache revs file with trailing data 777 recovery from invalid cache revs file with trailing data
622 $ echo >> .hg/cache/rbc-revs-v1 778 $ echo >> .hg/cache/rbc-revs-v1
623 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug 779 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
624 5 780 5
625 truncating cache/rbc-revs-v1 to 120 781 truncating cache/rbc-revs-v1 to 160
626 $ f --size .hg/cache/rbc-revs* 782 $ f --size .hg/cache/rbc-revs*
627 .hg/cache/rbc-revs-v1: size=120 783 .hg/cache/rbc-revs-v1: size=160
628 recovery from invalid cache file with partial last record 784 recovery from invalid cache file with partial last record
629 $ mv .hg/cache/rbc-revs-v1 . 785 $ mv .hg/cache/rbc-revs-v1 .
630 $ f -qDB 119 rbc-revs-v1 > .hg/cache/rbc-revs-v1 786 $ f -qDB 119 rbc-revs-v1 > .hg/cache/rbc-revs-v1
631 $ f --size .hg/cache/rbc-revs* 787 $ f --size .hg/cache/rbc-revs*
632 .hg/cache/rbc-revs-v1: size=119 788 .hg/cache/rbc-revs-v1: size=119
633 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug 789 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
634 5 790 5
635 truncating cache/rbc-revs-v1 to 112 791 truncating cache/rbc-revs-v1 to 112
636 $ f --size .hg/cache/rbc-revs* 792 $ f --size .hg/cache/rbc-revs*
637 .hg/cache/rbc-revs-v1: size=120 793 .hg/cache/rbc-revs-v1: size=160
638 recovery from invalid cache file with missing record - no truncation 794 recovery from invalid cache file with missing record - no truncation
639 $ mv .hg/cache/rbc-revs-v1 . 795 $ mv .hg/cache/rbc-revs-v1 .
640 $ f -qDB 112 rbc-revs-v1 > .hg/cache/rbc-revs-v1 796 $ f -qDB 112 rbc-revs-v1 > .hg/cache/rbc-revs-v1
641 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug 797 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
642 5 798 5
643 $ f --size .hg/cache/rbc-revs* 799 $ f --size .hg/cache/rbc-revs*
644 .hg/cache/rbc-revs-v1: size=120 800 .hg/cache/rbc-revs-v1: size=160
645 recovery from invalid cache file with some bad records 801 recovery from invalid cache file with some bad records
646 $ mv .hg/cache/rbc-revs-v1 . 802 $ mv .hg/cache/rbc-revs-v1 .
647 $ f -qDB 8 rbc-revs-v1 > .hg/cache/rbc-revs-v1 803 $ f -qDB 8 rbc-revs-v1 > .hg/cache/rbc-revs-v1
648 $ f --size .hg/cache/rbc-revs* 804 $ f --size .hg/cache/rbc-revs*
649 .hg/cache/rbc-revs-v1: size=8 805 .hg/cache/rbc-revs-v1: size=8
656 3 4 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 8 812 3 4 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 8
657 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug 813 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
658 5 814 5
659 truncating cache/rbc-revs-v1 to 104 815 truncating cache/rbc-revs-v1 to 104
660 $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs* 816 $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs*
661 .hg/cache/rbc-revs-v1: size=120 817 .hg/cache/rbc-revs-v1: size=160
662 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| 818 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
663 cache is updated when committing 819 cache is updated when committing
664 $ hg branch i-will-regret-this 820 $ hg branch i-will-regret-this
665 marked working directory as branch i-will-regret-this 821 marked working directory as branch i-will-regret-this
666 $ hg ci -m regrets 822 $ hg ci -m regrets
667 $ f --size .hg/cache/rbc-* 823 $ f --size .hg/cache/rbc-*
668 .hg/cache/rbc-names-v1: size=106 824 .hg/cache/rbc-names-v1: size=111
669 .hg/cache/rbc-revs-v1: size=128 825 .hg/cache/rbc-revs-v1: size=168
670 update after rollback - the cache will be correct but rbc-names will will still 826 update after rollback - the cache will be correct but rbc-names will will still
671 contain the branch name even though it no longer is used 827 contain the branch name even though it no longer is used
672 $ hg up -qr '.^' 828 $ hg up -qr '.^'
673 $ hg rollback -qf 829 $ hg rollback -qf
674 $ f --size --hexdump .hg/cache/rbc-* 830 $ f --size --hexdump .hg/cache/rbc-*
675 .hg/cache/rbc-names-v1: size=106 831 .hg/cache/rbc-names-v1: size=111
676 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a | 832 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
677 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much| 833 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
678 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the| 834 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
679 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi| 835 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
680 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b| 836 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
681 0050: 72 61 6e 63 68 65 73 00 69 2d 77 69 6c 6c 2d 72 |ranches.i-will-r| 837 0050: 72 61 6e 63 68 65 73 00 6d 00 6d 64 00 69 2d 77 |ranches.m.md.i-w|
682 0060: 65 67 72 65 74 2d 74 68 69 73 |egret-this| 838 0060: 69 6c 6c 2d 72 65 67 72 65 74 2d 74 68 69 73 |ill-regret-this|
683 .hg/cache/rbc-revs-v1: size=120 839 .hg/cache/rbc-revs-v1: size=160
684 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| 840 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
685 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....| 841 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
686 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................| 842 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
687 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....| 843 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
688 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....| 844 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
689 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....| 845 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
690 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....| 846 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
691 0070: f8 94 c2 56 80 00 00 03 |...V....| 847 0070: f8 94 c2 56 80 00 00 03 f3 44 76 37 00 00 00 05 |...V.....Dv7....|
848 0080: a5 8c a5 d3 00 00 00 05 df 34 3b 0d 00 00 00 05 |.........4;.....|
849 0090: c9 14 c9 9f 00 00 00 06 cd 21 a8 0b 80 00 00 05 |.........!......|
692 cache is updated/truncated when stripping - it is thus very hard to get in a 850 cache is updated/truncated when stripping - it is thus very hard to get in a
693 situation where the cache is out of sync and the hash check detects it 851 situation where the cache is out of sync and the hash check detects it
694 $ hg --config extensions.strip= strip -r tip --nob 852 $ hg --config extensions.strip= strip -r tip --nob
695 $ f --size .hg/cache/rbc-revs* 853 $ f --size .hg/cache/rbc-revs*
696 .hg/cache/rbc-revs-v1: size=112 854 .hg/cache/rbc-revs-v1: size=152
697 855
698 cache is rebuilt when corruption is detected 856 cache is rebuilt when corruption is detected
699 $ echo > .hg/cache/rbc-names-v1 857 $ echo > .hg/cache/rbc-names-v1
700 $ hg log -r '5:&branch(.)' -T '{rev} ' --debug 858 $ hg log -r '5:&branch(.)' -T '{rev} ' --debug
701 referenced branch names not found - rebuilding revision branch cache from scratch 859 referenced branch names not found - rebuilding revision branch cache from scratch
702 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 40 860 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 40
703 $ f --size --hexdump .hg/cache/rbc-* 861 $ f --size --hexdump .hg/cache/rbc-*
704 .hg/cache/rbc-names-v1: size=79 862 .hg/cache/rbc-names-v1: size=84
705 0000: 62 00 61 00 63 00 61 20 62 72 61 6e 63 68 20 6e |b.a.c.a branch n| 863 0000: 62 00 61 00 63 00 61 20 62 72 61 6e 63 68 20 6e |b.a.c.a branch n|
706 0010: 61 6d 65 20 6d 75 63 68 20 6c 6f 6e 67 65 72 20 |ame much longer | 864 0010: 61 6d 65 20 6d 75 63 68 20 6c 6f 6e 67 65 72 20 |ame much longer |
707 0020: 74 68 61 6e 20 74 68 65 20 64 65 66 61 75 6c 74 |than the default| 865 0020: 74 68 61 6e 20 74 68 65 20 64 65 66 61 75 6c 74 |than the default|
708 0030: 20 6a 75 73 74 69 66 69 63 61 74 69 6f 6e 20 75 | justification u| 866 0030: 20 6a 75 73 74 69 66 69 63 61 74 69 6f 6e 20 75 | justification u|
709 0040: 73 65 64 20 62 79 20 62 72 61 6e 63 68 65 73 |sed by branches| 867 0040: 73 65 64 20 62 79 20 62 72 61 6e 63 68 65 73 00 |sed by branches.|
710 .hg/cache/rbc-revs-v1: size=112 868 0050: 6d 00 6d 64 |m.md|
869 .hg/cache/rbc-revs-v1: size=152
711 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 870 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
712 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 871 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
713 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 01 |................| 872 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 01 |................|
714 0030: 58 97 36 a2 00 00 00 02 10 ff 58 95 00 00 00 03 |X.6.......X.....| 873 0030: 58 97 36 a2 00 00 00 02 10 ff 58 95 00 00 00 03 |X.6.......X.....|
715 0040: ee bb 94 44 00 00 00 00 5f 40 61 bb 00 00 00 00 |...D...._@a.....| 874 0040: ee bb 94 44 00 00 00 00 5f 40 61 bb 00 00 00 00 |...D...._@a.....|
716 0050: bf be 84 1b 00 00 00 00 d3 f1 63 45 80 00 00 00 |..........cE....| 875 0050: bf be 84 1b 00 00 00 00 d3 f1 63 45 80 00 00 00 |..........cE....|
717 0060: e3 d4 9c 05 80 00 00 00 e2 3b 55 05 00 00 00 00 |.........;U.....| 876 0060: e3 d4 9c 05 80 00 00 00 e2 3b 55 05 00 00 00 00 |.........;U.....|
877 0070: f8 94 c2 56 80 00 00 02 f3 44 76 37 00 00 00 04 |...V.....Dv7....|
878 0080: a5 8c a5 d3 00 00 00 04 df 34 3b 0d 00 00 00 04 |.........4;.....|
879 0090: c9 14 c9 9f 00 00 00 05 |........|
718 880
719 Test that cache files are created and grows correctly: 881 Test that cache files are created and grows correctly:
720 882
721 $ rm .hg/cache/rbc* 883 $ rm .hg/cache/rbc*
722 $ hg log -r "5 & branch(5)" -T "{rev}\n" 884 $ hg log -r "5 & branch(5)" -T "{rev}\n"
723 5 885 5
724 $ f --size --hexdump .hg/cache/rbc-* 886 $ f --size --hexdump .hg/cache/rbc-*
725 .hg/cache/rbc-names-v1: size=1 887 .hg/cache/rbc-names-v1: size=1
726 0000: 61 |a| 888 0000: 61 |a|
727 .hg/cache/rbc-revs-v1: size=112 889 .hg/cache/rbc-revs-v1: size=152
728 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 890 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
729 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 891 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
730 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 00 |................| 892 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 00 |................|
731 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 893 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
732 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 894 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
733 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 895 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
734 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 896 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
897 0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
898 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
899 0090: 00 00 00 00 00 00 00 00 |........|
735 900
736 $ cd .. 901 $ cd ..
737 902
738 Test for multiple incorrect branch cache entries: 903 Test for multiple incorrect branch cache entries:
739 904