673
673
self.assertFalse(repo._format.supports_external_lookups)
676
class Test2a(TestCaseWithTransport):
678
def test_format_pack_compresses_True(self):
679
repo = self.make_repository('repo', format='2a')
680
self.assertTrue(repo._format.pack_compresses)
676
class TestDevelopment6(TestCaseWithTransport):
682
678
def test_inventories_use_chk_map_with_parent_base_dict(self):
683
tree = self.make_branch_and_tree('repo', format="2a")
679
tree = self.make_branch_and_tree('repo', format="development6-rich-root")
684
680
revid = tree.commit("foo")
686
682
self.addCleanup(tree.unlock)
692
688
self.assertEqual(65536,
693
689
inv.parent_id_basename_to_file_id._root_node.maximum_size)
695
def test_autopack_unchanged_chk_nodes(self):
696
# at 20 unchanged commits, chk pages are packed that are split into
697
# two groups such that the new pack being made doesn't have all its
698
# pages in the source packs (though they are in the repository).
699
tree = self.make_branch_and_tree('tree', format='2a')
700
for pos in range(20):
701
tree.commit(str(pos))
703
def test_pack_with_hint(self):
704
tree = self.make_branch_and_tree('tree', format='2a')
705
# 1 commit to leave untouched
707
to_keep = tree.branch.repository._pack_collection.names()
711
all = tree.branch.repository._pack_collection.names()
712
combine = list(set(all) - set(to_keep))
713
self.assertLength(3, all)
714
self.assertLength(2, combine)
715
tree.branch.repository.pack(hint=combine)
716
final = tree.branch.repository._pack_collection.names()
717
self.assertLength(2, final)
718
self.assertFalse(combine[0] in final)
719
self.assertFalse(combine[1] in final)
720
self.assertSubset(to_keep, final)
722
691
def test_stream_source_to_gc(self):
723
source = self.make_repository('source', format='2a')
724
target = self.make_repository('target', format='2a')
692
source = self.make_repository('source', format='development6-rich-root')
693
target = self.make_repository('target', format='development6-rich-root')
725
694
stream = source._get_source(target._format)
726
695
self.assertIsInstance(stream, groupcompress_repo.GroupCHKStreamSource)
728
697
def test_stream_source_to_non_gc(self):
729
source = self.make_repository('source', format='2a')
698
source = self.make_repository('source', format='development6-rich-root')
730
699
target = self.make_repository('target', format='rich-root-pack')
731
700
stream = source._get_source(target._format)
732
701
# We don't want the child GroupCHKStreamSource
797
766
self.assertEqual(257, len(full_chk_records))
798
767
self.assertSubset(simple_chk_records, full_chk_records)
800
def test_inconsistency_fatal(self):
801
repo = self.make_repository('repo', format='2a')
802
self.assertTrue(repo.revisions._index._inconsistency_fatal)
803
self.assertFalse(repo.texts._index._inconsistency_fatal)
804
self.assertFalse(repo.inventories._index._inconsistency_fatal)
805
self.assertFalse(repo.signatures._index._inconsistency_fatal)
806
self.assertFalse(repo.chk_bytes._index._inconsistency_fatal)
809
770
class TestKnitPackStreamSource(tests.TestCaseWithMemoryTransport):
1393
1354
self.assertTrue(new_pack.inventory_index._optimize_for_size)
1394
1355
self.assertTrue(new_pack.text_index._optimize_for_size)
1395
1356
self.assertTrue(new_pack.signature_index._optimize_for_size)
1398
class TestCrossFormatPacks(TestCaseWithTransport):
1400
def log_pack(self, hint=None):
1401
self.calls.append(('pack', hint))
1402
self.orig_pack(hint=hint)
1403
if self.expect_hint:
1404
self.assertTrue(hint)
1406
def run_stream(self, src_fmt, target_fmt, expect_pack_called):
1407
self.expect_hint = expect_pack_called
1409
source_tree = self.make_branch_and_tree('src', format=src_fmt)
1410
source_tree.lock_write()
1411
self.addCleanup(source_tree.unlock)
1412
tip = source_tree.commit('foo')
1413
target = self.make_repository('target', format=target_fmt)
1415
self.addCleanup(target.unlock)
1416
source = source_tree.branch.repository._get_source(target._format)
1417
self.orig_pack = target.pack
1418
target.pack = self.log_pack
1419
search = target.search_missing_revision_ids(
1420
source_tree.branch.repository, tip)
1421
stream = source.get_stream(search)
1422
from_format = source_tree.branch.repository._format
1423
sink = target._get_sink()
1424
sink.insert_stream(stream, from_format, [])
1425
if expect_pack_called:
1426
self.assertLength(1, self.calls)
1428
self.assertLength(0, self.calls)
1430
def run_fetch(self, src_fmt, target_fmt, expect_pack_called):
1431
self.expect_hint = expect_pack_called
1433
source_tree = self.make_branch_and_tree('src', format=src_fmt)
1434
source_tree.lock_write()
1435
self.addCleanup(source_tree.unlock)
1436
tip = source_tree.commit('foo')
1437
target = self.make_repository('target', format=target_fmt)
1439
self.addCleanup(target.unlock)
1440
source = source_tree.branch.repository
1441
self.orig_pack = target.pack
1442
target.pack = self.log_pack
1443
target.fetch(source)
1444
if expect_pack_called:
1445
self.assertLength(1, self.calls)
1447
self.assertLength(0, self.calls)
1449
def test_sink_format_hint_no(self):
1450
# When the target format says packing makes no difference, pack is not
1452
self.run_stream('1.9', 'rich-root-pack', False)
1454
def test_sink_format_hint_yes(self):
1455
# When the target format says packing makes a difference, pack is
1457
self.run_stream('1.9', '2a', True)
1459
def test_sink_format_same_no(self):
1460
# When the formats are the same, pack is not called.
1461
self.run_stream('2a', '2a', False)
1463
def test_IDS_format_hint_no(self):
1464
# When the target format says packing makes no difference, pack is not
1466
self.run_fetch('1.9', 'rich-root-pack', False)
1468
def test_IDS_format_hint_yes(self):
1469
# When the target format says packing makes a difference, pack is
1471
self.run_fetch('1.9', '2a', True)
1473
def test_IDS_format_same_no(self):
1474
# When the formats are the same, pack is not called.
1475
self.run_fetch('2a', '2a', False)