/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_pack_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-07 13:56:43 UTC
  • mfrom: (4241.6.9 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090407135643-r15qstzbwg87d2nq
(robertc) Add --development6-rich-root,
        disabling the legacy and unneeded development2 format,
        and activating the tests for CHK features disabled pending this format.
        (Robert Collins, John Arbash Meinel, Ian Clathworthy, Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    upgrade,
39
39
    workingtree,
40
40
    )
 
41
from bzrlib.repofmt.groupcompress_repo import RepositoryFormatCHK1
41
42
from bzrlib.smart import (
42
43
    client,
43
44
    server,
208
209
        tree = tree.bzrdir.open_workingtree()
209
210
        check_result = tree.branch.repository.check(
210
211
            [tree.branch.last_revision()])
211
 
        # We should have 50 (10x5) files in the obsolete_packs directory.
 
212
        nb_files = 5 # .pack, .rix, .iix, .tix, .six
 
213
        if tree.branch.repository._format.supports_chks:
 
214
            nb_files += 1 # .cix
 
215
        # We should have 10 x nb_files files in the obsolete_packs directory.
212
216
        obsolete_files = list(trans.list_dir('obsolete_packs'))
213
217
        self.assertFalse('foo' in obsolete_files)
214
218
        self.assertFalse('bar' in obsolete_files)
215
 
        self.assertEqual(50, len(obsolete_files))
 
219
        self.assertEqual(10 * nb_files, len(obsolete_files))
216
220
        # XXX: Todo check packs obsoleted correctly - old packs and indices
217
221
        # in the obsolete_packs directory.
218
222
        large_pack_name = list(index.iter_all_entries())[0][1][0]
252
256
        self.assertEqual(2, len(tree.branch.repository.all_revision_ids()))
253
257
 
254
258
    def test_pack_layout(self):
 
259
        # Test that the ordering of revisions in pack repositories is
 
260
        # tip->ancestor
255
261
        format = self.get_format()
 
262
        if type(format.repository_format) is RepositoryFormatCHK1:
 
263
            raise TestSkipped("Not updated for GroupCompress internals")
256
264
        tree = self.make_branch_and_tree('.', format=format)
257
265
        trans = tree.branch.repository.bzrdir.get_repository_transport(None)
258
266
        tree.commit('start', rev_id='1')
283
291
 
284
292
    def _add_text(self, repo, fileid):
285
293
        """Add a text to the repository within a write group."""
286
 
        repo.texts.add_lines((fileid, 'samplerev+'+fileid), [], [])
 
294
        repo.texts.add_lines((fileid, 'samplerev+'+fileid), [],
 
295
            ['smaplerev+'+fileid])
287
296
 
288
297
    def test_concurrent_writers_merge_new_packs(self):
289
298
        format = self.get_format()
543
552
    def test_missing_inventories_compression_parent_prevents_commit(self):
544
553
        repo = self.make_write_ready_repo()
545
554
        key = ('junk',)
 
555
        if not getattr(repo.inventories._index, '_missing_compression_parents',
 
556
            None):
 
557
            raise TestSkipped("No missing compression parents")
546
558
        repo.inventories._index._missing_compression_parents.add(key)
547
559
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
548
560
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
552
564
    def test_missing_revisions_compression_parent_prevents_commit(self):
553
565
        repo = self.make_write_ready_repo()
554
566
        key = ('junk',)
 
567
        if not getattr(repo.inventories._index, '_missing_compression_parents',
 
568
            None):
 
569
            raise TestSkipped("No missing compression parents")
555
570
        repo.revisions._index._missing_compression_parents.add(key)
556
571
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
557
572
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
561
576
    def test_missing_signatures_compression_parent_prevents_commit(self):
562
577
        repo = self.make_write_ready_repo()
563
578
        key = ('junk',)
 
579
        if not getattr(repo.inventories._index, '_missing_compression_parents',
 
580
            None):
 
581
            raise TestSkipped("No missing compression parents")
564
582
        repo.signatures._index._missing_compression_parents.add(key)
565
583
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
566
584
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
570
588
    def test_missing_text_compression_parent_prevents_commit(self):
571
589
        repo = self.make_write_ready_repo()
572
590
        key = ('some', 'junk')
 
591
        if not getattr(repo.inventories._index, '_missing_compression_parents',
 
592
            None):
 
593
            raise TestSkipped("No missing compression parents")
573
594
        repo.texts._index._missing_compression_parents.add(key)
574
595
        self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
575
596
        e = self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
699
720
            # can only stack on repositories that have compatible internal
700
721
            # metadata
701
722
            if getattr(repo._format, 'supports_tree_reference', False):
702
 
                matching_format_name = 'pack-0.92-subtree'
 
723
                if repo._format.supports_chks:
 
724
                    matching_format_name = 'development6-rich-root'
 
725
                else:
 
726
                    matching_format_name = 'pack-0.92-subtree'
703
727
            else:
704
728
                matching_format_name = 'rich-root-pack'
705
729
            mismatching_format_name = 'pack-0.92'
706
730
        else:
707
 
            matching_format_name = 'pack-0.92'
 
731
            # We don't have a non-rich-root CHK format.
 
732
            if repo._format.supports_chks:
 
733
                raise AssertionError("no non-rich-root CHK formats known")
 
734
            else:
 
735
                matching_format_name = 'pack-0.92'
708
736
            mismatching_format_name = 'pack-0.92-subtree'
709
737
        base = self.make_repository('base', format=matching_format_name)
710
738
        repo.add_fallback_repository(base)
715
743
            repo.add_fallback_repository, bad_repo)
716
744
        self.assertContainsRe(str(e),
717
745
            r'(?m)KnitPackRepository.*/mismatch/.*\nis not compatible with\n'
718
 
            r'KnitPackRepository.*/repo/.*\n'
 
746
            r'.*Repository.*/repo/.*\n'
719
747
            r'different rich-root support')
720
748
 
721
749
    def test_stack_checks_serializers_compatibility(self):
723
751
        if getattr(repo._format, 'supports_tree_reference', False):
724
752
            # can only stack on repositories that have compatible internal
725
753
            # metadata
726
 
            matching_format_name = 'pack-0.92-subtree'
 
754
            if repo._format.supports_chks:
 
755
                # No CHK subtree formats in bzr.dev, so this doesn't execute.
 
756
                matching_format_name = 'development6-subtree'
 
757
            else:
 
758
                matching_format_name = 'pack-0.92-subtree'
727
759
            mismatching_format_name = 'rich-root-pack'
728
760
        else:
729
761
            if repo.supports_rich_root():
741
773
            repo.add_fallback_repository, bad_repo)
742
774
        self.assertContainsRe(str(e),
743
775
            r'(?m)KnitPackRepository.*/mismatch/.*\nis not compatible with\n'
744
 
            r'KnitPackRepository.*/repo/.*\n'
 
776
            r'.*Repository.*/repo/.*\n'
745
777
            r'different serializers')
746
778
 
747
779
    def test_adding_pack_does_not_record_pack_names_from_other_repositories(self):
757
789
        self.assertEqual(1, len(new_instance._pack_collection.all_packs()))
758
790
 
759
791
    def test_autopack_only_considers_main_repo_packs(self):
760
 
        base = self.make_branch_and_tree('base', format=self.get_format())
 
792
        format = self.get_format()
 
793
        base = self.make_branch_and_tree('base', format=format)
761
794
        base.commit('foo')
762
 
        tree = self.make_branch_and_tree('repo', format=self.get_format())
 
795
        tree = self.make_branch_and_tree('repo', format=format)
763
796
        tree.branch.repository.add_fallback_repository(base.branch.repository)
764
797
        trans = tree.branch.repository.bzrdir.get_repository_transport(None)
765
798
        # This test could be a little cheaper by replacing the packs
780
813
        tree = tree.bzrdir.open_workingtree()
781
814
        check_result = tree.branch.repository.check(
782
815
            [tree.branch.last_revision()])
783
 
        # We should have 50 (10x5) files in the obsolete_packs directory.
 
816
        nb_files = 5 # .pack, .rix, .iix, .tix, .six
 
817
        if tree.branch.repository._format.supports_chks:
 
818
            nb_files += 1 # .cix
 
819
        # We should have 10 x nb_files files in the obsolete_packs directory.
784
820
        obsolete_files = list(trans.list_dir('obsolete_packs'))
785
821
        self.assertFalse('foo' in obsolete_files)
786
822
        self.assertFalse('bar' in obsolete_files)
787
 
        self.assertEqual(50, len(obsolete_files))
 
823
        self.assertEqual(10 * nb_files, len(obsolete_files))
788
824
        # XXX: Todo check packs obsoleted correctly - old packs and indices
789
825
        # in the obsolete_packs directory.
790
826
        large_pack_name = list(index.iter_all_entries())[0][1][0]
818
854
 
819
855
    def test_autopack_or_streaming_rpc_is_used_when_using_hpss(self):
820
856
        # Make local and remote repos
821
 
        tree = self.make_branch_and_tree('local', format=self.get_format())
822
 
        self.make_branch_and_tree('remote', format=self.get_format())
 
857
        format = self.get_format()
 
858
        tree = self.make_branch_and_tree('local', format=format)
 
859
        self.make_branch_and_tree('remote', format=format)
823
860
        remote_branch_url = self.smart_server.get_url() + 'remote'
824
861
        remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch()
825
862
        # Make 9 local revisions, and push them one at a time to the remote
879
916
                  "(bzr 1.9)\n",
880
917
              format_supports_external_lookups=True,
881
918
              index_class=BTreeGraphIndex),
882
 
         dict(format_name='development2',
883
 
              format_string="Bazaar development format 2 "
884
 
                  "(needs bzr.dev from before 1.8)\n",
885
 
              format_supports_external_lookups=True,
886
 
              index_class=BTreeGraphIndex),
887
 
         dict(format_name='development2-subtree',
888
 
              format_string="Bazaar development format 2 "
889
 
                  "with subtree support (needs bzr.dev from before 1.8)\n",
890
 
              format_supports_external_lookups=True,
 
919
         dict(format_name='development6-rich-root',
 
920
              format_string='Bazaar development format - group compression '
 
921
                  'and chk inventory (needs bzr.dev from 1.14)\n',
 
922
              format_supports_external_lookups=False,
891
923
              index_class=BTreeGraphIndex),
892
924
         ]
893
925
    # name of the scenario is the format name