397
399
# Arguably, the deserialise_inventory should detect a mismatch, and
398
400
# raise an error, rather than silently using one revision_id over the
400
inv = repo.deserialise_inventory('test-rev-id', inv_xml)
402
self.assertRaises(AssertionError, repo.deserialise_inventory,
403
'test-rev-id', inv_xml)
404
inv = repo.deserialise_inventory('other-rev-id', inv_xml)
401
405
self.assertEqual('other-rev-id', inv.root.revision)
432
436
('text-d', ['text-c'], test_knit.TEXT_1),
433
437
('text-m', ['text-b', 'text-d'], test_knit.TEXT_1),
439
# This test is actually a bit strict as the order in which they're
440
# returned is not defined. This matches the current (deterministic)
435
442
expected_data_list = [
436
443
# version, options, parents
437
444
('text-a', ['fulltext'], []),
438
445
('text-b', ['line-delta'], ['text-a']),
446
('text-m', ['line-delta'], ['text-b', 'text-d']),
439
447
('text-c', ['fulltext'], []),
440
448
('text-d', ['line-delta'], ['text-c']),
441
('text-m', ['line-delta'], ['text-b', 'text-d']),
443
450
for version_id, parents, lines in test_data:
444
451
k1.add_lines(version_id, parents, test_knit.split_lines(lines))
446
453
bytes = knitrepo._get_stream_as_bytes(
447
k1, ['text-a', 'text-b', 'text-c', 'text-d', 'text-m'])
454
k1, ['text-a', 'text-b', 'text-m', 'text-c', 'text-d', ])
449
456
data = bencode.bdecode(bytes)
450
457
format = data.pop(0)
752
759
broken_repo = self.make_broken_repository()
753
760
empty_repo = self.make_repository('empty-repo')
754
stream = broken_repo.get_data_stream(['rev1a', 'rev2', 'rev3'])
761
search = graph.SearchResult(set(['rev1a', 'rev2', 'rev3']),
762
set(), 3, ['rev1a', 'rev2', 'rev3'])
763
stream = broken_repo.get_data_stream_for_search(search)
755
764
empty_repo.lock_write()
756
765
self.addCleanup(empty_repo.unlock)
757
766
empty_repo.start_write_group()
926
935
self.assertEqual(1, len(list(index.iter_all_entries())))
927
936
self.assertEqual(2, len(tree.branch.repository.all_revision_ids()))
938
def test_pack_layout(self):
939
format = self.get_format()
940
tree = self.make_branch_and_tree('.', format=format)
941
trans = tree.branch.repository.bzrdir.get_repository_transport(None)
942
tree.commit('start', rev_id='1')
943
tree.commit('more work', rev_id='2')
944
tree.branch.repository.pack()
946
self.addCleanup(tree.unlock)
947
pack = tree.branch.repository._pack_collection.get_pack_by_name(
948
tree.branch.repository._pack_collection.names()[0])
949
# revision access tends to be tip->ancestor, so ordering that way on
950
# disk is a good idea.
951
for _1, key, val, refs in pack.revision_index.iter_all_entries():
953
pos_1 = int(val[1:].split()[0])
955
pos_2 = int(val[1:].split()[0])
956
self.assertTrue(pos_2 < pos_1)
929
958
def test_pack_repositories_support_multiple_write_locks(self):
930
959
format = self.get_format()
931
960
self.make_repository('.', shared=True, format=format)
1192
1221
repo = self.make_repository('.', format=format)
1193
1222
packs = repo._pack_collection
1194
1223
self.assertEqual([0], packs.pack_distribution(0))
1225
def test_ensure_loaded_unlocked(self):
1226
format = self.get_format()
1227
repo = self.make_repository('.', format=format)
1228
self.assertRaises(errors.ObjectNotLocked,
1229
repo._pack_collection.ensure_loaded)
1196
1231
def test_pack_distribution_one_to_nine(self):
1197
1232
format = self.get_format()
1198
1233
repo = self.make_repository('.', format=format)
1403
1438
# To date, this class has been factored out and nothing new added to it;
1404
1439
# thus there are not yet any tests.
1442
class TestInterDifferingSerializer(TestCaseWithTransport):
1444
def test_progress_bar(self):
1445
tree = self.make_branch_and_tree('tree')
1446
tree.commit('rev1', rev_id='rev-1')
1447
tree.commit('rev2', rev_id='rev-2')
1448
tree.commit('rev3', rev_id='rev-3')
1449
repo = self.make_repository('repo')
1450
inter_repo = repository.InterDifferingSerializer(
1451
tree.branch.repository, repo)
1452
pb = progress.InstrumentedProgress(to_file=StringIO())
1453
pb.never_throttle = True
1454
inter_repo.fetch('rev-1', pb)
1455
self.assertEqual('Transferring revisions', pb.last_msg)
1456
self.assertEqual(1, pb.last_cnt)
1457
self.assertEqual(1, pb.last_total)
1458
inter_repo.fetch('rev-3', pb)
1459
self.assertEqual(2, pb.last_cnt)
1460
self.assertEqual(2, pb.last_total)