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