~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

(tanner) land brisbane-core in safest possible way (Vincent Ladeuil,
        Robert Collins)

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
60
61
    upgrade,
61
62
    workingtree,
62
63
    )
63
 
from bzrlib.repofmt import knitrepo, weaverepo, pack_repo
 
64
from bzrlib.repofmt import (
 
65
    groupcompress_repo,
 
66
    knitrepo,
 
67
    pack_repo,
 
68
    weaverepo,
 
69
    )
64
70
 
65
71
 
66
72
class TestDefaultFormat(TestCase):
664
670
        self.assertFalse(repo._format.supports_external_lookups)
665
671
 
666
672
 
 
673
class TestDevelopment6(TestCaseWithTransport):
 
674
 
 
675
    def test_inventories_use_chk_map_with_parent_base_dict(self):
 
676
        tree = self.make_branch_and_tree('repo', format="development6-rich-root")
 
677
        revid = tree.commit("foo")
 
678
        tree.lock_read()
 
679
        self.addCleanup(tree.unlock)
 
680
        inv = tree.branch.repository.get_inventory(revid)
 
681
        self.assertNotEqual(None, inv.parent_id_basename_to_file_id)
 
682
        inv.parent_id_basename_to_file_id._ensure_root()
 
683
        inv.id_to_entry._ensure_root()
 
684
        self.assertEqual(65536, inv.id_to_entry._root_node.maximum_size)
 
685
        self.assertEqual(65536,
 
686
            inv.parent_id_basename_to_file_id._root_node.maximum_size)
 
687
 
 
688
 
 
689
class TestDevelopment6FindRevisionOutsideSet(TestCaseWithTransport):
 
690
    """Tests for _find_revision_outside_set."""
 
691
 
 
692
    def setUp(self):
 
693
        super(TestDevelopment6FindRevisionOutsideSet, self).setUp()
 
694
        self.builder = self.make_branch_builder('source',
 
695
            format='development6-rich-root')
 
696
        self.builder.start_series()
 
697
        self.builder.build_snapshot('initial', None,
 
698
            [('add', ('', 'tree-root', 'directory', None))])
 
699
        self.repo = self.builder.get_branch().repository
 
700
        self.addCleanup(self.builder.finish_series)
 
701
 
 
702
    def assertRevisionOutsideSet(self, expected_result, rev_set):
 
703
        self.assertEqual(
 
704
            expected_result, self.repo._find_revision_outside_set(rev_set))
 
705
 
 
706
    def test_simple(self):
 
707
        self.builder.build_snapshot('revid1', None, [])
 
708
        self.builder.build_snapshot('revid2', None, [])
 
709
        rev_set = ['revid2']
 
710
        self.assertRevisionOutsideSet('revid1', rev_set)
 
711
 
 
712
    def test_not_first_parent(self):
 
713
        self.builder.build_snapshot('revid1', None, [])
 
714
        self.builder.build_snapshot('revid2', None, [])
 
715
        self.builder.build_snapshot('revid3', None, [])
 
716
        rev_set = ['revid3', 'revid2']
 
717
        self.assertRevisionOutsideSet('revid1', rev_set)
 
718
 
 
719
    def test_not_null(self):
 
720
        rev_set = ['initial']
 
721
        self.assertRevisionOutsideSet(_mod_revision.NULL_REVISION, rev_set)
 
722
 
 
723
    def test_not_null_set(self):
 
724
        self.builder.build_snapshot('revid1', None, [])
 
725
        rev_set = [_mod_revision.NULL_REVISION]
 
726
        self.assertRevisionOutsideSet(_mod_revision.NULL_REVISION, rev_set)
 
727
 
 
728
    def test_ghost(self):
 
729
        self.builder.build_snapshot('revid1', None, [])
 
730
        rev_set = ['ghost', 'revid1']
 
731
        self.assertRevisionOutsideSet('initial', rev_set)
 
732
 
 
733
    def test_ghost_parent(self):
 
734
        self.builder.build_snapshot('revid1', None, [])
 
735
        self.builder.build_snapshot('revid2', ['revid1', 'ghost'], [])
 
736
        rev_set = ['revid2', 'revid1']
 
737
        self.assertRevisionOutsideSet('initial', rev_set)
 
738
 
 
739
    def test_righthand_parent(self):
 
740
        self.builder.build_snapshot('revid1', None, [])
 
741
        self.builder.build_snapshot('revid2a', ['revid1'], [])
 
742
        self.builder.build_snapshot('revid2b', ['revid1'], [])
 
743
        self.builder.build_snapshot('revid3', ['revid2a', 'revid2b'], [])
 
744
        rev_set = ['revid3', 'revid2a']
 
745
        self.assertRevisionOutsideSet('revid2b', rev_set)
 
746
 
 
747
 
667
748
class TestWithBrokenRepo(TestCaseWithTransport):
668
749
    """These tests seem to be more appropriate as interface tests?"""
669
750
 
1050
1131
        pack_transport = self.get_transport('pack')
1051
1132
        index_transport = self.get_transport('index')
1052
1133
        upload_transport.mkdir('.')
1053
 
        collection = pack_repo.RepositoryPackCollection(repo=None,
 
1134
        collection = pack_repo.RepositoryPackCollection(
 
1135
            repo=None,
1054
1136
            transport=self.get_transport('.'),
1055
1137
            index_transport=index_transport,
1056
1138
            upload_transport=upload_transport,
1057
1139
            pack_transport=pack_transport,
1058
1140
            index_builder_class=BTreeBuilder,
1059
 
            index_class=BTreeGraphIndex)
 
1141
            index_class=BTreeGraphIndex,
 
1142
            use_chk_index=False)
1060
1143
        pack = pack_repo.NewPack(collection)
1061
1144
        self.assertIsInstance(pack.revision_index, BTreeBuilder)
1062
1145
        self.assertIsInstance(pack.inventory_index, BTreeBuilder)
1121
1204
        self.assertTrue(new_pack.inventory_index._optimize_for_size)
1122
1205
        self.assertTrue(new_pack.text_index._optimize_for_size)
1123
1206
        self.assertTrue(new_pack.signature_index._optimize_for_size)
 
1207
 
 
1208
 
 
1209
class TestGCCHKPackCollection(TestCaseWithTransport):
 
1210
 
 
1211
    def test_stream_source_to_gc(self):
 
1212
        source = self.make_repository('source', format='development6-rich-root')
 
1213
        target = self.make_repository('target', format='development6-rich-root')
 
1214
        stream = source._get_source(target._format)
 
1215
        self.assertIsInstance(stream, groupcompress_repo.GroupCHKStreamSource)
 
1216
 
 
1217
    def test_stream_source_to_non_gc(self):
 
1218
        source = self.make_repository('source', format='development6-rich-root')
 
1219
        target = self.make_repository('target', format='rich-root-pack')
 
1220
        stream = source._get_source(target._format)
 
1221
        # We don't want the child GroupCHKStreamSource
 
1222
        self.assertIs(type(stream), repository.StreamSource)