~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

create thread for bbc

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
                           UnsupportedFormatError,
33
33
                           )
34
34
from bzrlib import graph
 
35
from bzrlib.branchbuilder import BranchBuilder
35
36
from bzrlib.btree_index import BTreeBuilder, BTreeGraphIndex
36
37
from bzrlib.index import GraphIndex, InMemoryGraphIndex
37
38
from bzrlib.repository import RepositoryFormat
664
665
        self.assertFalse(repo._format.supports_external_lookups)
665
666
 
666
667
 
 
668
class TestDevelopment5(TestCaseWithTransport):
 
669
 
 
670
    def test_inventories_use_chk_map_with_parent_base_dict(self):
 
671
        tree = self.make_branch_and_tree('repo', format="development5")
 
672
        revid = tree.commit("foo")
 
673
        tree.lock_read()
 
674
        self.addCleanup(tree.unlock)
 
675
        inv = tree.branch.repository.get_inventory(revid)
 
676
        self.assertNotEqual(None, inv.parent_id_basename_to_file_id)
 
677
        inv.parent_id_basename_to_file_id._ensure_root()
 
678
        inv.id_to_entry._ensure_root()
 
679
        self.assertEqual(4096, inv.id_to_entry._root_node.maximum_size)
 
680
        self.assertEqual(4096,
 
681
            inv.parent_id_basename_to_file_id._root_node.maximum_size)
 
682
 
 
683
 
 
684
class TestDevelopment5FindRevisionOutsideSet(TestCaseWithTransport):
 
685
    """Tests for _find_revision_outside_set."""
 
686
 
 
687
    def setUp(self):
 
688
        super(TestDevelopment5FindRevisionOutsideSet, self).setUp()
 
689
        self.builder = self.make_branch_builder('source', format='development5')
 
690
        self.builder.start_series()
 
691
        self.builder.build_snapshot('initial', None,
 
692
            [('add', ('', 'tree-root', 'directory', None))])
 
693
        self.repo = self.builder.get_branch().repository
 
694
        self.addCleanup(self.builder.finish_series)
 
695
 
 
696
    def assertRevisionOutsideSet(self, expected_result, rev_set):
 
697
        self.assertEqual(
 
698
            expected_result, self.repo._find_revision_outside_set(rev_set))
 
699
 
 
700
    def test_simple(self):
 
701
        self.builder.build_snapshot('revid1', None, [])
 
702
        self.builder.build_snapshot('revid2', None, [])
 
703
        rev_set = ['revid2']
 
704
        self.assertRevisionOutsideSet('revid1', rev_set)
 
705
 
 
706
    def test_not_first_parent(self):
 
707
        self.builder.build_snapshot('revid1', None, [])
 
708
        self.builder.build_snapshot('revid2', None, [])
 
709
        self.builder.build_snapshot('revid3', None, [])
 
710
        rev_set = ['revid3', 'revid2']
 
711
        self.assertRevisionOutsideSet('revid1', rev_set)
 
712
 
 
713
    def test_not_null(self):
 
714
        rev_set = ['initial']
 
715
        self.assertRevisionOutsideSet(_mod_revision.NULL_REVISION, rev_set)
 
716
 
 
717
    def test_not_null_set(self):
 
718
        self.builder.build_snapshot('revid1', None, [])
 
719
        rev_set = [_mod_revision.NULL_REVISION]
 
720
        self.assertRevisionOutsideSet(_mod_revision.NULL_REVISION, rev_set)
 
721
 
 
722
    def test_ghost(self):
 
723
        self.builder.build_snapshot('revid1', None, [])
 
724
        rev_set = ['ghost', 'revid1']
 
725
        self.assertRevisionOutsideSet('initial', rev_set)
 
726
 
 
727
    def test_ghost_parent(self):
 
728
        self.builder.build_snapshot('revid1', None, [])
 
729
        self.builder.build_snapshot('revid2', ['revid1', 'ghost'], [])
 
730
        rev_set = ['revid2', 'revid1']
 
731
        self.assertRevisionOutsideSet('initial', rev_set)
 
732
 
 
733
    def test_righthand_parent(self):
 
734
        self.builder.build_snapshot('revid1', None, [])
 
735
        self.builder.build_snapshot('revid2a', ['revid1'], [])
 
736
        self.builder.build_snapshot('revid2b', ['revid1'], [])
 
737
        self.builder.build_snapshot('revid3', ['revid2a', 'revid2b'], [])
 
738
        rev_set = ['revid3', 'revid2a']
 
739
        self.assertRevisionOutsideSet('revid2b', rev_set)
 
740
 
 
741
 
667
742
class TestWithBrokenRepo(TestCaseWithTransport):
668
743
    """These tests seem to be more appropriate as interface tests?"""
669
744
 
1050
1125
        pack_transport = self.get_transport('pack')
1051
1126
        index_transport = self.get_transport('index')
1052
1127
        upload_transport.mkdir('.')
1053
 
        collection = pack_repo.RepositoryPackCollection(repo=None,
 
1128
        collection = pack_repo.RepositoryPackCollection(
 
1129
            repo=None,
1054
1130
            transport=self.get_transport('.'),
1055
1131
            index_transport=index_transport,
1056
1132
            upload_transport=upload_transport,
1057
1133
            pack_transport=pack_transport,
1058
1134
            index_builder_class=BTreeBuilder,
1059
 
            index_class=BTreeGraphIndex)
 
1135
            index_class=BTreeGraphIndex,
 
1136
            use_chk_index=False)
1060
1137
        pack = pack_repo.NewPack(collection)
1061
1138
        self.assertIsInstance(pack.revision_index, BTreeBuilder)
1062
1139
        self.assertIsInstance(pack.inventory_index, BTreeBuilder)