Rev 3227: Inspect Repository commit builder tests for places where a readonly copy can be a valid check. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

Robert Collins robertc at robertcollins.net
Mon Feb 18 03:58:42 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

------------------------------------------------------------
revno: 3227
revision-id:robertc at robertcollins.net-20080218035837-6h8bw9pxvxte6gix
parent: robertc at robertcollins.net-20080218033835-ukg71m7228deri5k
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository_implementations.split_read_write
timestamp: Mon 2008-02-18 14:58:37 +1100
message:
  Inspect Repository commit builder tests for places where a readonly copy can be a valid check.
modified:
  bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
=== modified file 'bzrlib/tests/repository_implementations/test_commit_builder.py'
--- a/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-10-26 19:18:48 +0000
+++ b/bzrlib/tests/repository_implementations/test_commit_builder.py	2008-02-18 03:58:37 +0000
@@ -87,7 +87,10 @@
             rev_id = builder.commit('foo bar blah')
         finally:
             tree.unlock()
-        rev = tree.branch.repository.get_revision(rev_id)
+        repo = self._make_test_read_instance(tree.branch.repository)
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        rev = repo.get_revision(rev_id)
         self.assertEqual('foo bar blah', rev.message)
 
     def test_commit_with_revision_id(self):
@@ -114,7 +117,10 @@
             self.assertEqual(revision_id, builder.commit('foo bar'))
         finally:
             tree.unlock()
-        self.assertTrue(tree.branch.repository.has_revision(revision_id))
+        repo = self._make_test_read_instance(tree.branch.repository)
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        self.assertTrue(repo.has_revision(revision_id))
         # the revision id must be set on the inventory when saving it. This
         # does not precisely test that - a repository that wants to can add it
         # on deserialisation, but thats all the current contract guarantees
@@ -181,10 +187,15 @@
             tree.unlock()
         self.assertNotEqual(None, rev_id)
         self.assertTrue(tree.branch.repository.has_revision(rev_id))
-        # the revision id must be set on the inventory when saving it. This does not
-        # precisely test that - a repository that wants to can add it on deserialisation,
-        # but thats all the current contract guarantees anyway.
-        self.assertEqual(rev_id, tree.branch.repository.get_inventory(rev_id).revision_id)
+        repo = self._make_test_read_instance(tree.branch.repository)
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        self.assertTrue(repo.has_revision(rev_id))
+        # the revision id must be set on the inventory when saving it. This
+        # does not precisely test that - a repository that wants to can add it
+        # on deserialisation, but thats all the current contract guarantees
+        # anyway.
+        self.assertEqual(rev_id, repo.get_inventory(rev_id).revision_id)
 
     def test_revision_tree(self):
         tree = self.make_branch_and_tree(".")
@@ -213,15 +224,16 @@
         self.assertEqual(rev_id, basis_tree.inventory.root.revision)
 
     def _get_revtrees(self, tree, revision_ids):
-        tree.lock_read()
+        repo = self._make_test_read_instance(tree.branch.repository)
+        repo.lock_read()
         try:
-            trees = list(tree.branch.repository.revision_trees(revision_ids))
+            trees = list(repo.revision_trees(revision_ids))
             for _tree in trees:
                 _tree.lock_read()
                 self.addCleanup(_tree.unlock)
             return trees
         finally:
-            tree.unlock()
+            repo.unlock()
 
     def test_last_modified_revision_after_commit_root_unchanged(self):
         # commiting without changing the root does not change the 
@@ -410,10 +422,10 @@
     def assertFileAncestry(self, ancestry, tree, name, alt_ancestry=None):
         # all the changes that have occured should be in the ancestry
         # (closest to a public per-file graph API we have today)
-        tree.lock_read()
-        self.addCleanup(tree.unlock)
-        vw = tree.branch.repository.weave_store.get_weave(name + 'id',
-            tree.branch.repository.get_transaction())
+        repo = self._make_test_read_instance(tree.branch.repository)
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        vw = repo.weave_store.get_weave(name + 'id', repo.get_transaction())
         result = vw.get_ancestry([ancestry[-1]])
         if alt_ancestry is None:
             self.assertEqual(ancestry, result)



More information about the bazaar-commits mailing list