Rev 3237: Moar repository tests. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

Robert Collins robertc at robertcollins.net
Tue Feb 19 21:53:11 GMT 2008


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

------------------------------------------------------------
revno: 3237
revision-id:robertc at robertcollins.net-20080219215303-bww9pvax5dx2q5vz
parent: robertc at robertcollins.net-20080219044041-q6goelmps4yh77u9
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository_implementations.split_read_write
timestamp: Wed 2008-02-20 08:53:03 +1100
message:
  Moar repository tests.
modified:
  bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py	2008-02-12 02:38:27 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2008-02-19 21:53:03 +0000
@@ -84,10 +84,16 @@
         tree = self.make_branch_and_tree('a')
         first_revision = tree.commit('')
         second_revision = tree.commit('')
-        tree.lock_read()
-        self.addCleanup(tree.unlock)
+        repo = self._make_test_read_instance(tree.branch.repository)
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
         revs = (first_revision, second_revision)
-        invs = tree.branch.repository.iter_inventories(revs)
+        invs = repo.iter_inventories(revs)
+        for rev_id, inv in zip(revs, invs):
+            self.assertEqual(rev_id, inv.revision_id)
+            self.assertIsInstance(inv, Inventory)
+        revs = (second_revision, first_revision)
+        invs = repo.iter_inventories(revs)
         for rev_id, inv in zip(revs, invs):
             self.assertEqual(rev_id, inv.revision_id)
             self.assertIsInstance(inv, Inventory)
@@ -100,6 +106,9 @@
         rich_root = (inv.root.revision != second_revision)
         self.assertEqual(rich_root,
                          tree.branch.repository.supports_rich_root())
+        self.assertEqual(rich_root,
+            self._make_test_read_instance(
+                tree.branch.repository).supports_rich_root())
 
     def test_clone_specific_format(self):
         """todo"""
@@ -177,15 +186,16 @@
         wt = self.make_branch_and_tree('.')
         wt.set_root_id('fixed-root')
         wt.commit('lala!', rev_id='revision-1', allow_pointless=True)
-        tree = wt.branch.repository.revision_tree('revision-1')
-        self.assertEqual('revision-1', tree.inventory.root.revision) 
+        repo = self._make_test_read_instance(wt.branch.repository)
+        tree = repo.revision_tree('revision-1')
+        self.assertEqual('revision-1', tree.inventory.root.revision)
         expected = InventoryDirectory('fixed-root', '', None)
         expected.revision = 'revision-1'
         self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)],
                          list(tree.list_files(include_root=True)))
-        tree = wt.branch.repository.revision_tree(None)
+        tree = repo.revision_tree(None)
         self.assertEqual([], list(tree.list_files(include_root=True)))
-        tree = wt.branch.repository.revision_tree(NULL_REVISION)
+        tree = repo.revision_tree(NULL_REVISION)
         self.assertEqual([], list(tree.list_files(include_root=True)))
 
     def test_get_revision_delta(self):
@@ -197,10 +207,11 @@
         tree_a.add('vla', 'file2')
         tree_a.commit('rev2', rev_id='rev2')
 
-        delta = tree_a.branch.repository.get_revision_delta('rev1')
+        repo = self._make_test_read_instance(tree_a.branch.repository)
+        delta = repo.get_revision_delta('rev1')
         self.assertIsInstance(delta, TreeDelta)
         self.assertEqual([('foo', 'file1', 'file')], delta.added)
-        delta = tree_a.branch.repository.get_revision_delta('rev2')
+        delta = repo.get_revision_delta('rev2')
         self.assertIsInstance(delta, TreeDelta)
         self.assertEqual([('vla', 'file2', 'file')], delta.added)
 
@@ -259,7 +270,8 @@
         except errors.BadConversionTarget, e:
             raise TestSkipped(str(e))
         wt = WorkingTree.open(wt.basedir)
-        new_signature = wt.branch.repository.get_signature_text('A')
+        repo = self._make_test_read_instance(wt.branch.repository)
+        new_signature = repo.get_signature_text('A')
         self.assertEqual(old_signature, new_signature)
 
     def test_format_description(self):
@@ -276,7 +288,8 @@
         """Assert that message roundtrips to a repository and back intact."""
         tree = self.make_branch_and_tree('.')
         tree.commit(message, rev_id='a', allow_pointless=True)
-        rev = tree.branch.repository.get_revision('a')
+        repo = self._make_test_read_instance(tree.branch.repository)
+        rev = repo.get_revision('a')
         # we have to manually escape this as we dont try to
         # roundtrip xml invalid characters at this point.
         # when escaping is moved to the serialiser, this test
@@ -319,7 +332,7 @@
                     allow_pointless=True)
         tree.commit('third empty commit', rev_id='c-rev',
                     allow_pointless=True)
-        repo = tree.branch.repository
+        repo = self._make_test_read_instance(tree.branch.repository)
         revision_ids = ['a-rev', 'b-rev', 'c-rev']
         revisions = repo.get_revisions(revision_ids)
         assert len(revisions) == 3, repr(revisions)
@@ -335,36 +348,6 @@
         rev_tree = tree.branch.repository.revision_tree(tree.last_revision())
         self.assertEqual('rev_id', rev_tree.inventory.root.revision)
 
-    def DISABLED_DELETE_OR_FIX_BEFORE_MERGE_test_create_basis_inventory(self):
-        # Needs testing here because differences between repo and working tree
-        # basis inventory formats can lead to bugs.
-        t = self.make_branch_and_tree('.')
-        b = t.branch
-        open('a', 'wb').write('a\n')
-        t.add('a')
-        t.commit('a', rev_id='r1')
-
-        t._control_files.get_utf8('basis-inventory-cache')
-
-        basis_inv = t.basis_tree().inventory
-        self.assertEquals('r1', basis_inv.revision_id)
-        
-        store_inv = b.repository.get_inventory('r1')
-        self.assertEquals(store_inv._byid, basis_inv._byid)
-
-        open('b', 'wb').write('b\n')
-        t.add('b')
-        t.commit('b', rev_id='r2')
-
-        t._control_files.get_utf8('basis-inventory-cache')
-
-        basis_inv_txt = t.read_basis_inventory()
-        basis_inv = bzrlib.xml7.serializer_v7.read_inventory_from_string(basis_inv_txt)
-        self.assertEquals('r2', basis_inv.revision_id)
-        store_inv = b.repository.get_inventory('r2')
-
-        self.assertEquals(store_inv._byid, basis_inv._byid)
-
     def test_upgrade_from_format4(self):
         from bzrlib.tests.test_upgrade import _upgrade_dir_template
         if self.repository_format.get_format_description() \



More information about the bazaar-commits mailing list