~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-10-28 18:16:14 UTC
  • mfrom: (3789.1.11 pack_retry_153786-1)
  • Revision ID: pqm@pqm.ubuntu.com-20081028181614-p3qlghekhffb6cbu
(jam) First part of fixing #153786,
        CombinedGraphIndex reloads index list and retries operation.

Show diffs side-by-side

added added

removed removed

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