673
673
self.assertFalse(repo._format.supports_external_lookups)
676
class TestDevelopment6(TestCaseWithTransport):
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)
678
682
def test_inventories_use_chk_map_with_parent_base_dict(self):
679
tree = self.make_branch_and_tree('repo', format="development6-rich-root")
683
tree = self.make_branch_and_tree('repo', format="2a")
680
684
revid = tree.commit("foo")
682
686
self.addCleanup(tree.unlock)
688
692
self.assertEqual(65536,
689
693
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)
691
722
def test_stream_source_to_gc(self):
692
source = self.make_repository('source', format='development6-rich-root')
693
target = self.make_repository('target', format='development6-rich-root')
723
source = self.make_repository('source', format='2a')
724
target = self.make_repository('target', format='2a')
694
725
stream = source._get_source(target._format)
695
726
self.assertIsInstance(stream, groupcompress_repo.GroupCHKStreamSource)
697
728
def test_stream_source_to_non_gc(self):
698
source = self.make_repository('source', format='development6-rich-root')
729
source = self.make_repository('source', format='2a')
699
730
target = self.make_repository('target', format='rich-root-pack')
700
731
stream = source._get_source(target._format)
701
732
# We don't want the child GroupCHKStreamSource
1354
1385
self.assertTrue(new_pack.inventory_index._optimize_for_size)
1355
1386
self.assertTrue(new_pack.text_index._optimize_for_size)
1356
1387
self.assertTrue(new_pack.signature_index._optimize_for_size)
1390
class TestCrossFormatPacks(TestCaseWithTransport):
1392
def log_pack(self, hint=None):
1393
self.calls.append(('pack', hint))
1394
self.orig_pack(hint=hint)
1395
if self.expect_hint:
1396
self.assertTrue(hint)
1398
def run_stream(self, src_fmt, target_fmt, expect_pack_called):
1399
self.expect_hint = expect_pack_called
1401
source_tree = self.make_branch_and_tree('src', format=src_fmt)
1402
source_tree.lock_write()
1403
self.addCleanup(source_tree.unlock)
1404
tip = source_tree.commit('foo')
1405
target = self.make_repository('target', format=target_fmt)
1407
self.addCleanup(target.unlock)
1408
source = source_tree.branch.repository._get_source(target._format)
1409
self.orig_pack = target.pack
1410
target.pack = self.log_pack
1411
search = target.search_missing_revision_ids(
1412
source_tree.branch.repository, tip)
1413
stream = source.get_stream(search)
1414
from_format = source_tree.branch.repository._format
1415
sink = target._get_sink()
1416
sink.insert_stream(stream, from_format, [])
1417
if expect_pack_called:
1418
self.assertLength(1, self.calls)
1420
self.assertLength(0, self.calls)
1422
def run_fetch(self, src_fmt, target_fmt, expect_pack_called):
1423
self.expect_hint = expect_pack_called
1425
source_tree = self.make_branch_and_tree('src', format=src_fmt)
1426
source_tree.lock_write()
1427
self.addCleanup(source_tree.unlock)
1428
tip = source_tree.commit('foo')
1429
target = self.make_repository('target', format=target_fmt)
1431
self.addCleanup(target.unlock)
1432
source = source_tree.branch.repository
1433
self.orig_pack = target.pack
1434
target.pack = self.log_pack
1435
target.fetch(source)
1436
if expect_pack_called:
1437
self.assertLength(1, self.calls)
1439
self.assertLength(0, self.calls)
1441
def test_sink_format_hint_no(self):
1442
# When the target format says packing makes no difference, pack is not
1444
self.run_stream('1.9', 'rich-root-pack', False)
1446
def test_sink_format_hint_yes(self):
1447
# When the target format says packing makes a difference, pack is
1449
self.run_stream('1.9', '2a', True)
1451
def test_sink_format_same_no(self):
1452
# When the formats are the same, pack is not called.
1453
self.run_stream('2a', '2a', False)
1455
def test_IDS_format_hint_no(self):
1456
# When the target format says packing makes no difference, pack is not
1458
self.run_fetch('1.9', 'rich-root-pack', False)
1460
def test_IDS_format_hint_yes(self):
1461
# When the target format says packing makes a difference, pack is
1463
self.run_fetch('1.9', '2a', True)
1465
def test_IDS_format_same_no(self):
1466
# When the formats are the same, pack is not called.
1467
self.run_fetch('2a', '2a', False)