208
208
tree = tree.bzrdir.open_workingtree()
209
209
check_result = tree.branch.repository.check(
210
210
[tree.branch.last_revision()])
211
# We should have 50 (10x5) files in the obsolete_packs directory.
211
nb_files = 5 # .pack, .rix, .iix, .tix, .six
212
if tree.branch.repository._format.supports_chks:
214
# We should have 10 x nb_files files in the obsolete_packs directory.
212
215
obsolete_files = list(trans.list_dir('obsolete_packs'))
213
216
self.assertFalse('foo' in obsolete_files)
214
217
self.assertFalse('bar' in obsolete_files)
215
self.assertEqual(50, len(obsolete_files))
218
self.assertEqual(10 * nb_files, len(obsolete_files))
216
219
# XXX: Todo check packs obsoleted correctly - old packs and indices
217
220
# in the obsolete_packs directory.
218
221
large_pack_name = list(index.iter_all_entries())[0][1][0]
699
702
# can only stack on repositories that have compatible internal
701
704
if getattr(repo._format, 'supports_tree_reference', False):
702
matching_format_name = 'pack-0.92-subtree'
705
if repo._format.supports_chks:
706
matching_format_name = 'development5-subtree'
708
matching_format_name = 'pack-0.92-subtree'
704
710
matching_format_name = 'rich-root-pack'
705
711
mismatching_format_name = 'pack-0.92'
707
matching_format_name = 'pack-0.92'
713
if repo._format.supports_chks:
714
hash_key = repo._format._serializer.search_key_name
715
# At the moment, we don't allow stacking between various hash
717
if hash_key == 'plain':
718
matching_format_name = 'development5'
719
elif hash_key == 'hash-16-way':
720
matching_format_name = 'development5-hash16'
722
if hash_key != 'hash-255-way':
723
raise AssertionError("unhandled hash key: %s"
725
matching_format_name = 'development5-hash255'
727
matching_format_name = 'pack-0.92'
708
728
mismatching_format_name = 'pack-0.92-subtree'
709
729
base = self.make_repository('base', format=matching_format_name)
710
730
repo.add_fallback_repository(base)
715
735
repo.add_fallback_repository, bad_repo)
716
736
self.assertContainsRe(str(e),
717
737
r'(?m)KnitPackRepository.*/mismatch/.*\nis not compatible with\n'
718
r'KnitPackRepository.*/repo/.*\n'
738
r'.*Repository.*/repo/.*\n'
719
739
r'different rich-root support')
721
741
def test_stack_checks_serializers_compatibility(self):
723
743
if getattr(repo._format, 'supports_tree_reference', False):
724
744
# can only stack on repositories that have compatible internal
726
matching_format_name = 'pack-0.92-subtree'
746
if repo._format.supports_chks:
747
matching_format_name = 'development5-subtree'
749
matching_format_name = 'pack-0.92-subtree'
727
750
mismatching_format_name = 'rich-root-pack'
729
752
if repo.supports_rich_root():
741
764
repo.add_fallback_repository, bad_repo)
742
765
self.assertContainsRe(str(e),
743
766
r'(?m)KnitPackRepository.*/mismatch/.*\nis not compatible with\n'
744
r'KnitPackRepository.*/repo/.*\n'
767
r'.*Repository.*/repo/.*\n'
745
768
r'different serializers')
747
770
def test_adding_pack_does_not_record_pack_names_from_other_repositories(self):
757
780
self.assertEqual(1, len(new_instance._pack_collection.all_packs()))
759
782
def test_autopack_only_considers_main_repo_packs(self):
760
base = self.make_branch_and_tree('base', format=self.get_format())
783
format = self.get_format()
784
base = self.make_branch_and_tree('base', format=format)
761
785
base.commit('foo')
762
tree = self.make_branch_and_tree('repo', format=self.get_format())
786
tree = self.make_branch_and_tree('repo', format=format)
763
787
tree.branch.repository.add_fallback_repository(base.branch.repository)
764
788
trans = tree.branch.repository.bzrdir.get_repository_transport(None)
765
789
# This test could be a little cheaper by replacing the packs
780
804
tree = tree.bzrdir.open_workingtree()
781
805
check_result = tree.branch.repository.check(
782
806
[tree.branch.last_revision()])
783
# We should have 50 (10x5) files in the obsolete_packs directory.
807
nb_files = 5 # .pack, .rix, .iix, .tix, .six
808
if tree.branch.repository._format.supports_chks:
810
# We should have 10 x nb_files files in the obsolete_packs directory.
784
811
obsolete_files = list(trans.list_dir('obsolete_packs'))
785
812
self.assertFalse('foo' in obsolete_files)
786
813
self.assertFalse('bar' in obsolete_files)
787
self.assertEqual(50, len(obsolete_files))
814
self.assertEqual(10 * nb_files, len(obsolete_files))
788
815
# XXX: Todo check packs obsoleted correctly - old packs and indices
789
816
# in the obsolete_packs directory.
790
817
large_pack_name = list(index.iter_all_entries())[0][1][0]
819
846
def test_autopack_or_streaming_rpc_is_used_when_using_hpss(self):
820
847
# 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())
848
format = self.get_format()
849
tree = self.make_branch_and_tree('local', format=format)
850
self.make_branch_and_tree('remote', format=format)
823
851
remote_branch_url = self.smart_server.get_url() + 'remote'
824
852
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch()
825
853
# Make 9 local revisions, and push them one at a time to the remote
889
917
"with subtree support (needs bzr.dev from before 1.8)\n",
890
918
format_supports_external_lookups=True,
891
919
index_class=BTreeGraphIndex),
920
dict(format_name='development5',
921
# merge-bbc-dev4-to-bzr.dev
922
format_string="Bazaar development format 5 "
923
"(needs bzr.dev from before 1.13)\n",
924
format_supports_external_lookups=True,
925
index_class=BTreeGraphIndex),
926
dict(format_name='development5-subtree',
927
# merge-bbc-dev4-to-bzr.dev
928
format_string="Bazaar development format 5 "
929
"with subtree support (needs bzr.dev from before 1.13)\n",
930
format_supports_external_lookups=True,
931
index_class=BTreeGraphIndex),
932
dict(format_name='development5-hash16',
933
# merge-bbc-dev4-to-bzr.dev
934
format_string="Bazaar development format 5 hash 16"
935
" (needs bzr.dev from before 1.13)\n",
936
format_supports_external_lookups=True,
937
index_class=BTreeGraphIndex),
938
dict(format_name='development5-hash255',
939
# merge-bbc-dev4-to-bzr.dev
940
format_string="Bazaar development format 5 hash 255"
941
" (needs bzr.dev from before 1.13)\n",
942
format_supports_external_lookups=True,
943
index_class=BTreeGraphIndex),
893
945
# name of the scenario is the format name
894
946
scenarios = [(s['format_name'], s) for s in scenarios_params]