Rev 3229: More external reference tests. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

Robert Collins robertc at robertcollins.net
Wed Feb 20 04:43:40 GMT 2008


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

------------------------------------------------------------
revno: 3229
revision-id:robertc at robertcollins.net-20080220044335-5lazo5bxc43rmf5u
parent: robertc at robertcollins.net-20080220030028-c3r2ue2nd4h3a1th
parent: robertc at robertcollins.net-20080220030028-c3r2ue2nd4h3a1th
committer: Robert Collins <robertc at robertcollins.net>
branch nick: external_reference_tests
timestamp: Wed 2008-02-20 15:43:35 +1100
message:
  More external reference tests.
added:
  bzrlib/tests/repository_external_reference_implementations/test_add_revision.py test_add_revision.py-20080220034108-ao1u8qgakqbo5a08-1
  bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py test_add_signature_t-20080220041905-1j2g4lyz3c6h34v4-1
  bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py test_all_revision_id-20080220041905-1j2g4lyz3c6h34v4-2
  bzrlib/tests/repository_external_reference_implementations/test_break_lock.py test_break_lock.py-20080220042825-1f48qmpnuqqp5wg2-1
  bzrlib/tests/repository_external_reference_implementations/test_check.py test_check.py-20080220044229-sxxe747gzi6q8fyv-1
modified:
  bzrlib/tests/repository_external_reference_implementations/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
=== modified file 'bzrlib/tests/repository_external_reference_implementations/__init__.py'
--- a/bzrlib/tests/repository_external_reference_implementations/__init__.py	2008-02-20 03:00:28 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/__init__.py	2008-02-20 04:43:35 +0000
@@ -86,6 +86,11 @@
     prefix = module.__name__ + '.test_'
     test_repository_modules = [
         'add_inventory',
+        'add_revision',
+        'add_signature_text',
+        'all_revision_ids',
+        'break_lock',
+        'check',
         ]
     module_name_list = [prefix + module_name
         for module_name in test_repository_modules]

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_add_revision.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_add_revision.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_add_revision.py	2008-02-20 04:43:35 +0000
@@ -0,0 +1,51 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for add_revision on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAddRevision(TestCaseWithExternalReferenceRepository):
+
+    def test_add_revision_goes_to_repo(self):
+        # adding a revision only writes to the repository add_revision is
+        # called on.
+        tree = self.make_branch_and_tree('sample')
+        revid = tree.commit('one')
+        inv = tree.branch.repository.get_inventory(revid)
+        rev = tree.branch.repository.get_revision(revid)
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.lock_write()
+        try:
+            repo.start_write_group()
+            try:
+                rev = tree.branch.repository.get_revision(revid)
+                repo.add_revision(revid, rev, inv=inv)
+            except:
+                repo.abort_write_group()
+                raise
+            else:
+                repo.commit_write_group()
+        finally:
+            repo.unlock()
+        rev2 = repo.get_revision(revid)
+        self.assertEqual(rev, rev2)
+        self.assertRaises(errors.NoSuchRevision, base.get_revision, revid)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py	2008-02-20 04:43:35 +0000
@@ -0,0 +1,51 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for add_signature_text on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAddSignatureText(TestCaseWithExternalReferenceRepository):
+
+    def test_add_signature_text_goes_to_repo(self):
+        # adding a signature only writes to the repository add_signature_text
+        # is called on.
+        tree = self.make_branch_and_tree('sample')
+        revid = tree.commit('one')
+        inv = tree.branch.repository.get_inventory(revid)
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.lock_write()
+        try:
+            repo.start_write_group()
+            try:
+                rev = tree.branch.repository.get_revision(revid)
+                repo.add_revision(revid, rev, inv=inv)
+                repo.add_signature_text(revid, "text")
+            except:
+                repo.abort_write_group()
+                raise
+            else:
+                repo.commit_write_group()
+        finally:
+            repo.unlock()
+        repo.get_signature_text(revid)
+        self.assertRaises(errors.NoSuchRevision, base.get_signature_text,
+            revid)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py	2008-02-20 04:43:35 +0000
@@ -0,0 +1,64 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for all_revision_ids on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAllRevisionIds(TestCaseWithExternalReferenceRepository):
+
+    def test_all_revision_ids_empty(self):
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        self.assertEqual(set([]), repo.all_revision_ids())
+
+    def test_all_revision_ids_from_base(self):
+        tree = self.make_branch_and_tree('base')
+        revid = tree.commit('one')
+        repo = self.make_referring('referring', 'base')
+        self.assertEqual(set([revid]), repo.all_revision_ids())
+
+    def test_all_revision_ids_from_repo(self):
+        tree = self.make_branch_and_tree('spare')
+        revid = tree.commit('one')
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.fetch(tree.branch.repository, revid)
+        self.assertEqual(set([revid]), repo.all_revision_ids())
+
+    def test_all_revision_ids_from_both(self):
+        tree = self.make_branch_and_tree('spare')
+        revid = tree.commit('one')
+        base_tree = self.make_branch_and_tree('base')
+        revid2 = base_tree.commit('two')
+        repo = self.make_referring('referring', 'base')
+        repo.fetch(tree.branch.repository, revid)
+        self.assertEqual(set([revid, revid2]), repo.all_revision_ids())
+
+    def test_duplicate_ids_do_not_affect_length(self):
+        tree = self.make_branch_and_tree('spare')
+        revid = tree.commit('one')
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.fetch(tree.branch.repository, revid)
+        base.fetch(tree.branch.repository, revid)
+        self.assertEqual(set([revid]), repo.all_revision_ids())
+        self.assertEqual(1, len(repo.all_revision_ids()))
+

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_break_lock.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_break_lock.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_break_lock.py	2008-02-20 04:43:35 +0000
@@ -0,0 +1,50 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for break_lock on a repository with external references."""
+
+import bzrlib.ui
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestBreakLock(TestCaseWithExternalReferenceRepository):
+
+    def test_break_lock(self):
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        unused_repo = repo.bzrdir.open_repository()
+        base.lock_write()
+        self.addCleanup(base.unlock)
+        # break_lock when locked should
+        repo.lock_write()
+        self.assertEqual(repo.get_physical_lock_status(),
+            unused_repo.get_physical_lock_status())
+        if not unused_repo.get_physical_lock_status():
+            # 'lock_write' has not taken a physical mutex out.
+            repo.unlock()
+            return
+        # we want a UI factory that accepts canned input for the tests:
+        # while SilentUIFactory still accepts stdin, we need to customise
+        # ours
+        self.old_factory = bzrlib.ui.ui_factory
+        self.addCleanup(self.restoreFactory)
+        bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
+        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
+        unused_repo.break_lock()
+        self.assertRaises(errors.LockBroken, repo.unlock)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_check.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_check.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_check.py	2008-02-20 04:43:35 +0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for check on a repository with external references."""
+
+import bzrlib.ui
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestCheck(TestCaseWithExternalReferenceRepository):
+
+    def test_check_file_graph_across_external_boundary_ok(self):
+        tree = self.make_branch_and_tree('base')
+        self.build_tree(['base/file'])
+        tree.add(['file'], ['file-id'])
+        rev1_id = tree.commit('one')
+        referring = self.make_branch_and_tree('referring')
+        readonly_base = self.readonly_repository('base')
+        referring.branch.repository.add_fallback_repository(readonly_base)
+        self.build_tree_contents([('referring/file', 'change')])
+        rev2_id = referring.commit('two')
+        check_result = referring.branch.repository.check(
+            referring.branch.repository.all_revision_ids())
+        check_result.report_results(verbose=False)
+        log = self._get_log(keep_log_file=True)
+        self.assertContainsRe(
+            log,
+            "0 inconsistent parents")



More information about the bazaar-commits mailing list