923
923
# and the same instance should be returned on successive calls.
924
924
self.assertTrue(pack_1 is packs.get_pack_by_name(name))
926
def test_reload_pack_names_new_entry(self):
927
tree = self.make_branch_and_tree('.')
929
self.addCleanup(tree.unlock)
930
rev1 = tree.commit('one')
931
rev2 = tree.commit('two')
932
r = repository.Repository.open('.')
934
self.addCleanup(r.unlock)
935
packs = r._pack_collection
936
packs.ensure_loaded()
937
names = packs.names()
938
# Add a new pack file into the repository
939
rev3 = tree.commit('three')
940
new_names = tree.branch.repository._pack_collection.names()
941
new_name = set(new_names).difference(names)
942
self.assertEqual(1, len(new_name))
943
new_name = new_name.pop()
944
# The old collection hasn't noticed yet
945
self.assertEqual(names, packs.names())
946
self.assertTrue(packs.reload_pack_names())
947
self.assertEqual(new_names, packs.names())
948
# And the repository can access the new revision
949
self.assertEqual({rev3:(rev2,)}, r.get_parent_map([rev3]))
950
self.assertFalse(packs.reload_pack_names())
952
def test_reload_pack_names_added_and_removed(self):
953
tree = self.make_branch_and_tree('.')
955
self.addCleanup(tree.unlock)
956
rev1 = tree.commit('one')
957
rev2 = tree.commit('two')
958
r = repository.Repository.open('.')
960
self.addCleanup(r.unlock)
961
packs = r._pack_collection
962
packs.ensure_loaded()
963
names = packs.names()
964
# Now repack the whole thing
965
tree.branch.repository.pack()
966
new_names = tree.branch.repository._pack_collection.names()
967
# The other collection hasn't noticed yet
968
self.assertEqual(names, packs.names())
969
self.assertTrue(packs.reload_pack_names())
970
self.assertEqual(new_names, packs.names())
971
self.assertEqual({rev2:(rev1,)}, r.get_parent_map([rev2]))
972
self.assertFalse(packs.reload_pack_names())
927
975
class TestPack(TestCaseWithTransport):
928
976
"""Tests for the Pack object."""