/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
681
681
        self.assertFalse(repo._format.supports_external_lookups)
682
682
 
683
683
 
684
 
class Test2a(TestCaseWithTransport):
 
684
class Test2a(tests.TestCaseWithMemoryTransport):
 
685
 
 
686
    def test_fetch_combines_groups(self):
 
687
        builder = self.make_branch_builder('source', format='2a')
 
688
        builder.start_series()
 
689
        builder.build_snapshot('1', None, [
 
690
            ('add', ('', 'root-id', 'directory', '')),
 
691
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
692
        builder.build_snapshot('2', ['1'], [
 
693
            ('modify', ('file-id', 'content-2\n'))])
 
694
        builder.finish_series()
 
695
        source = builder.get_branch()
 
696
        target = self.make_repository('target', format='2a')
 
697
        target.fetch(source.repository)
 
698
        target.lock_read()
 
699
        self.addCleanup(target.unlock)
 
700
        details = target.texts._index.get_build_details(
 
701
            [('file-id', '1',), ('file-id', '2',)])
 
702
        file_1_details = details[('file-id', '1')]
 
703
        file_2_details = details[('file-id', '2')]
 
704
        # The index, and what to read off disk, should be the same for both
 
705
        # versions of the file.
 
706
        self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
 
707
 
 
708
    def test_fetch_combines_groups(self):
 
709
        builder = self.make_branch_builder('source', format='2a')
 
710
        builder.start_series()
 
711
        builder.build_snapshot('1', None, [
 
712
            ('add', ('', 'root-id', 'directory', '')),
 
713
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
714
        builder.build_snapshot('2', ['1'], [
 
715
            ('modify', ('file-id', 'content-2\n'))])
 
716
        builder.finish_series()
 
717
        source = builder.get_branch()
 
718
        target = self.make_repository('target', format='2a')
 
719
        target.fetch(source.repository)
 
720
        target.lock_read()
 
721
        self.addCleanup(target.unlock)
 
722
        details = target.texts._index.get_build_details(
 
723
            [('file-id', '1',), ('file-id', '2',)])
 
724
        file_1_details = details[('file-id', '1')]
 
725
        file_2_details = details[('file-id', '2')]
 
726
        # The index, and what to read off disk, should be the same for both
 
727
        # versions of the file.
 
728
        self.assertEqual(file_1_details[0][:3], file_2_details[0][:3])
685
729
 
686
730
    def test_fetch_combines_groups(self):
687
731
        builder = self.make_branch_builder('source', format='2a')
710
754
        self.assertTrue(repo._format.pack_compresses)
711
755
 
712
756
    def test_inventories_use_chk_map_with_parent_base_dict(self):
713
 
        tree = self.make_branch_and_tree('repo', format="2a")
 
757
        tree = self.make_branch_and_memory_tree('repo', format="2a")
 
758
        tree.lock_write()
 
759
        tree.add([''], ['TREE_ROOT'])
714
760
        revid = tree.commit("foo")
 
761
        tree.unlock()
715
762
        tree.lock_read()
716
763
        self.addCleanup(tree.unlock)
717
764
        inv = tree.branch.repository.get_inventory(revid)
726
773
        # at 20 unchanged commits, chk pages are packed that are split into
727
774
        # two groups such that the new pack being made doesn't have all its
728
775
        # pages in the source packs (though they are in the repository).
729
 
        tree = self.make_branch_and_tree('tree', format='2a')
 
776
        # Use a memory backed repository, we don't need to hit disk for this
 
777
        tree = self.make_branch_and_memory_tree('tree', format='2a')
 
778
        tree.lock_write()
 
779
        self.addCleanup(tree.unlock)
 
780
        tree.add([''], ['TREE_ROOT'])
730
781
        for pos in range(20):
731
782
            tree.commit(str(pos))
732
783
 
733
784
    def test_pack_with_hint(self):
734
 
        tree = self.make_branch_and_tree('tree', format='2a')
 
785
        tree = self.make_branch_and_memory_tree('tree', format='2a')
 
786
        tree.lock_write()
 
787
        self.addCleanup(tree.unlock)
 
788
        tree.add([''], ['TREE_ROOT'])
735
789
        # 1 commit to leave untouched
736
790
        tree.commit('1')
737
791
        to_keep = tree.branch.repository._pack_collection.names()