432
432
('text-d', ['text-c'], test_knit.TEXT_1),
433
433
('text-m', ['text-b', 'text-d'], test_knit.TEXT_1),
435
# This test is actually a bit strict as the order in which they're
436
# returned is not defined. This matches the current (deterministic)
435
438
expected_data_list = [
436
439
# version, options, parents
437
440
('text-a', ['fulltext'], []),
438
441
('text-b', ['line-delta'], ['text-a']),
442
('text-m', ['line-delta'], ['text-b', 'text-d']),
439
443
('text-c', ['fulltext'], []),
440
444
('text-d', ['line-delta'], ['text-c']),
441
('text-m', ['line-delta'], ['text-b', 'text-d']),
443
446
for version_id, parents, lines in test_data:
444
447
k1.add_lines(version_id, parents, test_knit.split_lines(lines))
446
449
bytes = knitrepo._get_stream_as_bytes(
447
k1, ['text-a', 'text-b', 'text-c', 'text-d', 'text-m'])
450
k1, ['text-a', 'text-b', 'text-m', 'text-c', 'text-d', ])
449
452
data = bencode.bdecode(bytes)
450
453
format = data.pop(0)
765
768
class TestKnitPackNoSubtrees(TestCaseWithTransport):
767
770
def get_format(self):
768
return bzrdir.format_registry.make_bzrdir('knitpack-experimental')
771
return bzrdir.format_registry.make_bzrdir('pack-0.92')
770
773
def test_disk_layout(self):
771
774
format = self.get_format()
926
929
self.assertEqual(1, len(list(index.iter_all_entries())))
927
930
self.assertEqual(2, len(tree.branch.repository.all_revision_ids()))
932
def test_pack_layout(self):
933
format = self.get_format()
934
tree = self.make_branch_and_tree('.', format=format)
935
trans = tree.branch.repository.bzrdir.get_repository_transport(None)
936
tree.commit('start', rev_id='1')
937
tree.commit('more work', rev_id='2')
938
tree.branch.repository.pack()
940
self.addCleanup(tree.unlock)
941
pack = tree.branch.repository._pack_collection.get_pack_by_name(
942
tree.branch.repository._pack_collection.names()[0])
943
# revision access tends to be tip->ancestor, so ordering that way on
944
# disk is a good idea.
945
for _1, key, val, refs in pack.revision_index.iter_all_entries():
947
pos_1 = int(val[1:].split()[0])
949
pos_2 = int(val[1:].split()[0])
950
self.assertTrue(pos_2 < pos_1)
929
952
def test_pack_repositories_support_multiple_write_locks(self):
930
953
format = self.get_format()
931
954
self.make_repository('.', shared=True, format=format)
1158
1181
class TestRepositoryPackCollection(TestCaseWithTransport):
1160
1183
def get_format(self):
1161
return bzrdir.format_registry.make_bzrdir('knitpack-experimental')
1184
return bzrdir.format_registry.make_bzrdir('pack-0.92')
1163
1186
def test__max_pack_count(self):
1164
1187
"""The maximum pack count is a function of the number of revisions."""
1192
1215
repo = self.make_repository('.', format=format)
1193
1216
packs = repo._pack_collection
1194
1217
self.assertEqual([0], packs.pack_distribution(0))
1219
def test_ensure_loaded_unlocked(self):
1220
format = self.get_format()
1221
repo = self.make_repository('.', format=format)
1222
self.assertRaises(errors.ObjectNotLocked,
1223
repo._pack_collection.ensure_loaded)
1196
1225
def test_pack_distribution_one_to_nine(self):
1197
1226
format = self.get_format()
1198
1227
repo = self.make_repository('.', format=format)