Rev 5709: (jelmer) Move some tests that rely on the full VersionedFiles API to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Mar 8 23:53:04 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5709 [merge]
revision-id: pqm at pqm.ubuntu.com-20110308235259-6yxq3x7vy60tfta3
parent: pqm at pqm.ubuntu.com-20110308224411-8ki4micmszepfnna
parent: jelmer at samba.org-20110308203743-wt47wgnh8zybqi5o
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-03-08 23:52:59 +0000
message:
  (jelmer) Move some tests that rely on the full VersionedFiles API to
   bzrlib.tests.per_repository_vf. (Jelmer Vernooij)
added:
  bzrlib/tests/per_repository_vf/ per_repository_vf-20110224144010-ukgfmlxcgsibq4u4-1
  bzrlib/tests/per_repository_vf/__init__.py __init__.py-20110224144010-ukgfmlxcgsibq4u4-2
  bzrlib/tests/per_repository_vf/test_repository.py test_repository.py-20110224144010-ukgfmlxcgsibq4u4-3
modified:
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repofmt/weaverepo.py    presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2011-03-03 07:16:12 +0000
+++ b/bzrlib/remote.py	2011-03-08 20:37:43 +0000
@@ -486,6 +486,8 @@
     """
 
     _matchingbzrdir = RemoteBzrDirFormat()
+    supports_full_versioned_files = True
+    supports_leaving_lock = True
 
     def __init__(self):
         repository.RepositoryFormat.__init__(self)
@@ -495,6 +497,7 @@
         self._supports_chks = None
         self._supports_external_lookups = None
         self._supports_tree_reference = None
+        self._supports_funky_characters = None
         self._rich_root_data = None
 
     def __repr__(self):
@@ -529,6 +532,14 @@
         return self._supports_external_lookups
 
     @property
+    def supports_funky_characters(self):
+        if self._supports_funky_characters is None:
+            self._ensure_real()
+            self._supports_funky_characters = \
+                self._custom_format.supports_funky_characters
+        return self._supports_funky_characters
+
+    @property
     def supports_tree_reference(self):
         if self._supports_tree_reference is None:
             self._ensure_real()

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2011-02-07 04:14:29 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2011-02-24 15:38:56 +0000
@@ -304,6 +304,8 @@
     _fetch_order = 'topological'
     _fetch_uses_deltas = True
     fast_deltas = False
+    supports_funky_characters = True
+    supports_full_versioned_files = True
 
     def _get_inventories(self, repo_transport, repo, name='inventory'):
         mapper = versionedfile.ConstantMapper(name)

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2011-02-21 23:31:07 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2011-03-05 04:10:42 +0000
@@ -2558,6 +2558,8 @@
     index_class = None
     _fetch_uses_deltas = True
     fast_deltas = False
+    supports_full_versioned_files = True
+    supports_funky_characters = True
 
     def initialize(self, a_bzrdir, shared=False):
         """Create a pack based repository.

=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py	2011-03-03 02:28:57 +0000
+++ b/bzrlib/repofmt/weaverepo.py	2011-03-05 04:10:42 +0000
@@ -278,6 +278,7 @@
     _fetch_reconcile = True
     fast_deltas = False
     supports_leaving_lock = False
+    supports_full_versioned_files = True
 
     def initialize(self, a_bzrdir, shared=False, _internal=False):
         """Create a weave repository."""
@@ -494,6 +495,7 @@
     supports_ghosts = False
     supports_chks = False
     supports_funky_characters = False
+    supports_full_versioned_files = True
 
     _fetch_order = 'topological'
     _fetch_reconcile = True

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2011-03-03 02:28:57 +0000
+++ b/bzrlib/repository.py	2011-03-05 04:10:42 +0000
@@ -3017,9 +3017,11 @@
     experimental = False
     # Does this repository format escape funky characters, or does it create files with
     # similar names as the versioned files in its contents on disk ?
-    supports_funky_characters = True
+    supports_funky_characters = None
     # Does this repository format support leaving locks?
-    supports_leaving_lock = True
+    supports_leaving_lock = None
+    # Does this format support the full VersionedFiles interface?
+    supports_full_versioned_files = None
 
     def __repr__(self):
         return "%s()" % self.__class__.__name__

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2011-03-03 11:32:03 +0000
+++ b/bzrlib/tests/__init__.py	2011-03-08 17:37:58 +0000
@@ -3711,6 +3711,7 @@
         'bzrlib.tests.per_repository',
         'bzrlib.tests.per_repository_chk',
         'bzrlib.tests.per_repository_reference',
+        'bzrlib.tests.per_repository_vf',
         'bzrlib.tests.per_uifactory',
         'bzrlib.tests.per_versionedfile',
         'bzrlib.tests.per_workingtree',

=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- a/bzrlib/tests/per_repository/test_repository.py	2011-03-03 02:28:57 +0000
+++ b/bzrlib/tests/per_repository/test_repository.py	2011-03-08 17:02:52 +0000
@@ -88,6 +88,18 @@
     def test_attribute_format_pack_compresses(self):
         self.assertFormatAttribute('pack_compresses', (True, False))
 
+    def test_attribute_format_supports_full_versioned_files(self):
+        self.assertFormatAttribute('supports_full_versioned_files',
+            (True, False))
+
+    def test_attribute_format_supports_funky_characters(self):
+        self.assertFormatAttribute('supports_funky_characters',
+            (True, False))
+
+    def test_attribute_format_supports_leaving_lock(self):
+        self.assertFormatAttribute('supports_leaving_lock',
+            (True, False))
+
     def test_format_is_deprecated(self):
         repo = self.make_repository('repo')
         self.assertSubset([repo._format.is_deprecated()], (True, False))
@@ -96,62 +108,6 @@
         repo = self.make_repository('repo')
         self.assertSubset([repo._format.is_supported()], (True, False))
 
-    def test_attribute_inventories_store(self):
-        """Test the existence of the inventories attribute."""
-        tree = self.make_branch_and_tree('tree')
-        repo = tree.branch.repository
-        self.assertIsInstance(repo.inventories, versionedfile.VersionedFiles)
-
-    def test_attribute_inventories_basics(self):
-        """Test basic aspects of the inventories attribute."""
-        tree = self.make_branch_and_tree('tree')
-        repo = tree.branch.repository
-        rev_id = (tree.commit('a'),)
-        tree.lock_read()
-        self.addCleanup(tree.unlock)
-        self.assertEqual(set([rev_id]), set(repo.inventories.keys()))
-
-    def test_attribute_revision_store(self):
-        """Test the existence of the revisions attribute."""
-        tree = self.make_branch_and_tree('tree')
-        repo = tree.branch.repository
-        self.assertIsInstance(repo.revisions,
-            versionedfile.VersionedFiles)
-
-    def test_attribute_revision_store_basics(self):
-        """Test the basic behaviour of the revisions attribute."""
-        tree = self.make_branch_and_tree('tree')
-        repo = tree.branch.repository
-        repo.lock_write()
-        try:
-            self.assertEqual(set(), set(repo.revisions.keys()))
-            revid = (tree.commit("foo"),)
-            self.assertEqual(set([revid]), set(repo.revisions.keys()))
-            self.assertEqual({revid:()},
-                repo.revisions.get_parent_map([revid]))
-        finally:
-            repo.unlock()
-        tree2 = self.make_branch_and_tree('tree2')
-        tree2.pull(tree.branch)
-        left_id = (tree2.commit('left'),)
-        right_id = (tree.commit('right'),)
-        tree.merge_from_branch(tree2.branch)
-        merge_id = (tree.commit('merged'),)
-        repo.lock_read()
-        self.addCleanup(repo.unlock)
-        self.assertEqual(set([revid, left_id, right_id, merge_id]),
-            set(repo.revisions.keys()))
-        self.assertEqual({revid:(), left_id:(revid,), right_id:(revid,),
-             merge_id:(right_id, left_id)},
-            repo.revisions.get_parent_map(repo.revisions.keys()))
-
-    def test_attribute_signature_store(self):
-        """Test the existence of the signatures attribute."""
-        tree = self.make_branch_and_tree('tree')
-        repo = tree.branch.repository
-        self.assertIsInstance(repo.signatures,
-            versionedfile.VersionedFiles)
-
     def test_attribute_text_store_basics(self):
         """Test the basic behaviour of the text store."""
         tree = self.make_branch_and_tree('tree')

=== added directory 'bzrlib/tests/per_repository_vf'
=== added file 'bzrlib/tests/per_repository_vf/__init__.py'
--- a/bzrlib/tests/per_repository_vf/__init__.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_repository_vf/__init__.py	2011-03-08 17:37:58 +0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+"""Implementation tests for VersionedFile-based repositories.
+
+For more generic per-repository tests, see bzrlib.tests.per_repository.
+"""
+
+from bzrlib.tests.per_repository import (
+    all_repository_format_scenarios,
+    TestCaseWithRepository,
+    )
+
+
+def all_repository_vf_format_scenarios():
+    scenarios = []
+    for test_name, scenario_info in all_repository_format_scenarios():
+        format = scenario_info['repository_format']
+        if format.supports_full_versioned_files:
+            scenarios.append((test_name, scenario_info))
+    return scenarios
+
+
+def load_tests(basic_tests, module, loader):
+    testmod_names = [
+        'test_repository',
+        ]
+    basic_tests.addTest(loader.loadTestsFromModuleNames(
+            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
+    return basic_tests

=== added file 'bzrlib/tests/per_repository_vf/test_repository.py'
--- a/bzrlib/tests/per_repository_vf/test_repository.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_repository_vf/test_repository.py	2011-03-08 17:29:19 +0000
@@ -0,0 +1,91 @@
+# Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for repository implementations - tests a repository format."""
+
+from bzrlib import (
+    versionedfile,
+    )
+
+from bzrlib.tests.per_repository_vf import (
+    TestCaseWithRepository,
+    all_repository_vf_format_scenarios,
+    )
+from bzrlib.tests.scenarios import load_tests_apply_scenarios
+
+
+load_tests = load_tests_apply_scenarios
+
+
+class TestRepository(TestCaseWithRepository):
+
+    scenarios = all_repository_vf_format_scenarios()
+
+    def test_attribute_inventories_store(self):
+        """Test the existence of the inventories attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        self.assertIsInstance(repo.inventories, versionedfile.VersionedFiles)
+
+    def test_attribute_inventories_basics(self):
+        """Test basic aspects of the inventories attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        rev_id = (tree.commit('a'),)
+        tree.lock_read()
+        self.addCleanup(tree.unlock)
+        self.assertEqual(set([rev_id]), set(repo.inventories.keys()))
+
+    def test_attribute_revision_store(self):
+        """Test the existence of the revisions attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        self.assertIsInstance(repo.revisions,
+            versionedfile.VersionedFiles)
+
+    def test_attribute_revision_store_basics(self):
+        """Test the basic behaviour of the revisions attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        repo.lock_write()
+        try:
+            self.assertEqual(set(), set(repo.revisions.keys()))
+            revid = (tree.commit("foo"),)
+            self.assertEqual(set([revid]), set(repo.revisions.keys()))
+            self.assertEqual({revid:()},
+                repo.revisions.get_parent_map([revid]))
+        finally:
+            repo.unlock()
+        tree2 = self.make_branch_and_tree('tree2')
+        tree2.pull(tree.branch)
+        left_id = (tree2.commit('left'),)
+        right_id = (tree.commit('right'),)
+        tree.merge_from_branch(tree2.branch)
+        merge_id = (tree.commit('merged'),)
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        self.assertEqual(set([revid, left_id, right_id, merge_id]),
+            set(repo.revisions.keys()))
+        self.assertEqual({revid:(), left_id:(revid,), right_id:(revid,),
+             merge_id:(right_id, left_id)},
+            repo.revisions.get_parent_map(repo.revisions.keys()))
+
+    def test_attribute_signature_store(self):
+        """Test the existence of the signatures attribute."""
+        tree = self.make_branch_and_tree('tree')
+        repo = tree.branch.repository
+        self.assertIsInstance(repo.signatures,
+            versionedfile.VersionedFiles)

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-03-08 16:00:55 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-03-08 23:52:59 +0000
@@ -186,6 +186,12 @@
   (``bzrlib.repository.format_registry``) rather than using the class
   methods on ``RepositoryFormat``. (Jelmer Vernooij)
 
+* Repository formats can now indicate they do not support the full
+  VersionedFiles API by setting the ``supports_full_versioned_files``
+  attribute to False. A subset of the VersionedFiles API
+  (signatures and text graphs) still needs to be supported.
+  (Jelmer Vernooij)
+
 * Repository formats have a new method ``is_deprecated`` that
   implementations can override to return True to trigger a deprecation
   warning. (Jelmer Vernooij)




More information about the bazaar-commits mailing list