~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Andrew Bennetts
  • Date: 2008-10-28 05:50:42 UTC
  • mfrom: (3789.1.9 pack_retry_153786)
  • mto: This revision was merged to the branch mainline in revision 3814.
  • Revision ID: andrew.bennetts@canonical.com-20081028055042-kr2z2vroqiljpse6
Merge John's pack-retry fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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))
926
926
 
 
927
    def test_reload_pack_names_new_entry(self):
 
928
        tree = self.make_branch_and_tree('.')
 
929
        tree.lock_write()
 
930
        self.addCleanup(tree.unlock)
 
931
        rev1 = tree.commit('one')
 
932
        rev2 = tree.commit('two')
 
933
        r = repository.Repository.open('.')
 
934
        r.lock_read()
 
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())
 
952
 
 
953
    def test_reload_pack_names_added_and_removed(self):
 
954
        tree = self.make_branch_and_tree('.')
 
955
        tree.lock_write()
 
956
        self.addCleanup(tree.unlock)
 
957
        rev1 = tree.commit('one')
 
958
        rev2 = tree.commit('two')
 
959
        r = repository.Repository.open('.')
 
960
        r.lock_read()
 
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())
 
974
 
927
975
 
928
976
class TestPack(TestCaseWithTransport):
929
977
    """Tests for the Pack object."""