Merge lp:~jelmer/bzr/per-repository-vf into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5709
Proposed branch: lp:~jelmer/bzr/per-repository-vf
Merge into: lp:bzr
Diff against target: 360 lines (+175/-58)
10 files modified
bzrlib/remote.py (+11/-0)
bzrlib/repofmt/knitrepo.py (+2/-0)
bzrlib/repofmt/pack_repo.py (+2/-0)
bzrlib/repofmt/weaverepo.py (+2/-0)
bzrlib/repository.py (+4/-2)
bzrlib/tests/__init__.py (+1/-0)
bzrlib/tests/per_repository/test_repository.py (+12/-56)
bzrlib/tests/per_repository_vf/__init__.py (+44/-0)
bzrlib/tests/per_repository_vf/test_repository.py (+91/-0)
doc/en/release-notes/bzr-2.4.txt (+6/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/per-repository-vf
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Fixing
Review via email: mp+51150@code.launchpad.net

Commit message

Move some tests that rely on the full VersionedFiles API to bzrlib.tests.per_repository_vf.

Description of the change

Add bzrlib.tests.per_repository_vf and move some tests to it. These tests only get run for repositories that claim to support the full VersionedFiles API; this currently means all current Bazaar formats.

Also, set some of the other RepositoryFormat flags to None by default and add tests to make sure that mplementations set them.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

148 +def load_tests(standard_tests, module, loader):
149 + scenarios = []
150 + for test_name, scenario_info in all_repository_format_scenarios():
151 + format = scenario_info['repository_format']
152 + if format.supports_full_versioned_files:
153 + scenarios.append((test_name, scenario_info))
154 + result = loader.suiteClass()
155 + tests = loader.loadTestsFromModuleNames([
156 + 'bzrlib.tests.per_repository_vf.test_repository'])
157 + multiply_tests(tests, scenarios, result)
158 + return result

Hmm, wouldn't it be better to use a scenarios attribute in test_repository.py instead of having the parametrization done in a separate file ?

I'm a bit concerned about the next dev that will try to add tests in this directory...

Other than that, ok to land.

review: Needs Fixing
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/remote.py'
2--- bzrlib/remote.py 2011-03-03 07:16:12 +0000
3+++ bzrlib/remote.py 2011-03-08 20:41:55 +0000
4@@ -486,6 +486,8 @@
5 """
6
7 _matchingbzrdir = RemoteBzrDirFormat()
8+ supports_full_versioned_files = True
9+ supports_leaving_lock = True
10
11 def __init__(self):
12 repository.RepositoryFormat.__init__(self)
13@@ -495,6 +497,7 @@
14 self._supports_chks = None
15 self._supports_external_lookups = None
16 self._supports_tree_reference = None
17+ self._supports_funky_characters = None
18 self._rich_root_data = None
19
20 def __repr__(self):
21@@ -529,6 +532,14 @@
22 return self._supports_external_lookups
23
24 @property
25+ def supports_funky_characters(self):
26+ if self._supports_funky_characters is None:
27+ self._ensure_real()
28+ self._supports_funky_characters = \
29+ self._custom_format.supports_funky_characters
30+ return self._supports_funky_characters
31+
32+ @property
33 def supports_tree_reference(self):
34 if self._supports_tree_reference is None:
35 self._ensure_real()
36
37=== modified file 'bzrlib/repofmt/knitrepo.py'
38--- bzrlib/repofmt/knitrepo.py 2011-02-07 04:14:29 +0000
39+++ bzrlib/repofmt/knitrepo.py 2011-03-08 20:41:55 +0000
40@@ -304,6 +304,8 @@
41 _fetch_order = 'topological'
42 _fetch_uses_deltas = True
43 fast_deltas = False
44+ supports_funky_characters = True
45+ supports_full_versioned_files = True
46
47 def _get_inventories(self, repo_transport, repo, name='inventory'):
48 mapper = versionedfile.ConstantMapper(name)
49
50=== modified file 'bzrlib/repofmt/pack_repo.py'
51--- bzrlib/repofmt/pack_repo.py 2011-02-21 23:31:07 +0000
52+++ bzrlib/repofmt/pack_repo.py 2011-03-08 20:41:55 +0000
53@@ -2558,6 +2558,8 @@
54 index_class = None
55 _fetch_uses_deltas = True
56 fast_deltas = False
57+ supports_full_versioned_files = True
58+ supports_funky_characters = True
59
60 def initialize(self, a_bzrdir, shared=False):
61 """Create a pack based repository.
62
63=== modified file 'bzrlib/repofmt/weaverepo.py'
64--- bzrlib/repofmt/weaverepo.py 2011-03-03 02:28:57 +0000
65+++ bzrlib/repofmt/weaverepo.py 2011-03-08 20:41:55 +0000
66@@ -278,6 +278,7 @@
67 _fetch_reconcile = True
68 fast_deltas = False
69 supports_leaving_lock = False
70+ supports_full_versioned_files = True
71
72 def initialize(self, a_bzrdir, shared=False, _internal=False):
73 """Create a weave repository."""
74@@ -494,6 +495,7 @@
75 supports_ghosts = False
76 supports_chks = False
77 supports_funky_characters = False
78+ supports_full_versioned_files = True
79
80 _fetch_order = 'topological'
81 _fetch_reconcile = True
82
83=== modified file 'bzrlib/repository.py'
84--- bzrlib/repository.py 2011-03-03 02:28:57 +0000
85+++ bzrlib/repository.py 2011-03-08 20:41:55 +0000
86@@ -3017,9 +3017,11 @@
87 experimental = False
88 # Does this repository format escape funky characters, or does it create files with
89 # similar names as the versioned files in its contents on disk ?
90- supports_funky_characters = True
91+ supports_funky_characters = None
92 # Does this repository format support leaving locks?
93- supports_leaving_lock = True
94+ supports_leaving_lock = None
95+ # Does this format support the full VersionedFiles interface?
96+ supports_full_versioned_files = None
97
98 def __repr__(self):
99 return "%s()" % self.__class__.__name__
100
101=== modified file 'bzrlib/tests/__init__.py'
102--- bzrlib/tests/__init__.py 2011-03-03 11:32:03 +0000
103+++ bzrlib/tests/__init__.py 2011-03-08 20:41:55 +0000
104@@ -3711,6 +3711,7 @@
105 'bzrlib.tests.per_repository',
106 'bzrlib.tests.per_repository_chk',
107 'bzrlib.tests.per_repository_reference',
108+ 'bzrlib.tests.per_repository_vf',
109 'bzrlib.tests.per_uifactory',
110 'bzrlib.tests.per_versionedfile',
111 'bzrlib.tests.per_workingtree',
112
113=== modified file 'bzrlib/tests/per_repository/test_repository.py'
114--- bzrlib/tests/per_repository/test_repository.py 2011-03-03 02:28:57 +0000
115+++ bzrlib/tests/per_repository/test_repository.py 2011-03-08 20:41:55 +0000
116@@ -88,6 +88,18 @@
117 def test_attribute_format_pack_compresses(self):
118 self.assertFormatAttribute('pack_compresses', (True, False))
119
120+ def test_attribute_format_supports_full_versioned_files(self):
121+ self.assertFormatAttribute('supports_full_versioned_files',
122+ (True, False))
123+
124+ def test_attribute_format_supports_funky_characters(self):
125+ self.assertFormatAttribute('supports_funky_characters',
126+ (True, False))
127+
128+ def test_attribute_format_supports_leaving_lock(self):
129+ self.assertFormatAttribute('supports_leaving_lock',
130+ (True, False))
131+
132 def test_format_is_deprecated(self):
133 repo = self.make_repository('repo')
134 self.assertSubset([repo._format.is_deprecated()], (True, False))
135@@ -96,62 +108,6 @@
136 repo = self.make_repository('repo')
137 self.assertSubset([repo._format.is_supported()], (True, False))
138
139- def test_attribute_inventories_store(self):
140- """Test the existence of the inventories attribute."""
141- tree = self.make_branch_and_tree('tree')
142- repo = tree.branch.repository
143- self.assertIsInstance(repo.inventories, versionedfile.VersionedFiles)
144-
145- def test_attribute_inventories_basics(self):
146- """Test basic aspects of the inventories attribute."""
147- tree = self.make_branch_and_tree('tree')
148- repo = tree.branch.repository
149- rev_id = (tree.commit('a'),)
150- tree.lock_read()
151- self.addCleanup(tree.unlock)
152- self.assertEqual(set([rev_id]), set(repo.inventories.keys()))
153-
154- def test_attribute_revision_store(self):
155- """Test the existence of the revisions attribute."""
156- tree = self.make_branch_and_tree('tree')
157- repo = tree.branch.repository
158- self.assertIsInstance(repo.revisions,
159- versionedfile.VersionedFiles)
160-
161- def test_attribute_revision_store_basics(self):
162- """Test the basic behaviour of the revisions attribute."""
163- tree = self.make_branch_and_tree('tree')
164- repo = tree.branch.repository
165- repo.lock_write()
166- try:
167- self.assertEqual(set(), set(repo.revisions.keys()))
168- revid = (tree.commit("foo"),)
169- self.assertEqual(set([revid]), set(repo.revisions.keys()))
170- self.assertEqual({revid:()},
171- repo.revisions.get_parent_map([revid]))
172- finally:
173- repo.unlock()
174- tree2 = self.make_branch_and_tree('tree2')
175- tree2.pull(tree.branch)
176- left_id = (tree2.commit('left'),)
177- right_id = (tree.commit('right'),)
178- tree.merge_from_branch(tree2.branch)
179- merge_id = (tree.commit('merged'),)
180- repo.lock_read()
181- self.addCleanup(repo.unlock)
182- self.assertEqual(set([revid, left_id, right_id, merge_id]),
183- set(repo.revisions.keys()))
184- self.assertEqual({revid:(), left_id:(revid,), right_id:(revid,),
185- merge_id:(right_id, left_id)},
186- repo.revisions.get_parent_map(repo.revisions.keys()))
187-
188- def test_attribute_signature_store(self):
189- """Test the existence of the signatures attribute."""
190- tree = self.make_branch_and_tree('tree')
191- repo = tree.branch.repository
192- self.assertIsInstance(repo.signatures,
193- versionedfile.VersionedFiles)
194-
195 def test_attribute_text_store_basics(self):
196 """Test the basic behaviour of the text store."""
197 tree = self.make_branch_and_tree('tree')
198
199=== added directory 'bzrlib/tests/per_repository_vf'
200=== added file 'bzrlib/tests/per_repository_vf/__init__.py'
201--- bzrlib/tests/per_repository_vf/__init__.py 1970-01-01 00:00:00 +0000
202+++ bzrlib/tests/per_repository_vf/__init__.py 2011-03-08 20:41:55 +0000
203@@ -0,0 +1,44 @@
204+# Copyright (C) 2011 Canonical Ltd
205+#
206+# This program is free software; you can redistribute it and/or modify
207+# it under the terms of the GNU General Public License as published by
208+# the Free Software Foundation; either version 2 of the License, or
209+# (at your option) any later version.
210+#
211+# This program is distributed in the hope that it will be useful,
212+# but WITHOUT ANY WARRANTY; without even the implied warranty of
213+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
214+# GNU General Public License for more details.
215+#
216+# You should have received a copy of the GNU General Public License
217+# along with this program; if not, write to the Free Software
218+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
219+
220+
221+"""Implementation tests for VersionedFile-based repositories.
222+
223+For more generic per-repository tests, see bzrlib.tests.per_repository.
224+"""
225+
226+from bzrlib.tests.per_repository import (
227+ all_repository_format_scenarios,
228+ TestCaseWithRepository,
229+ )
230+
231+
232+def all_repository_vf_format_scenarios():
233+ scenarios = []
234+ for test_name, scenario_info in all_repository_format_scenarios():
235+ format = scenario_info['repository_format']
236+ if format.supports_full_versioned_files:
237+ scenarios.append((test_name, scenario_info))
238+ return scenarios
239+
240+
241+def load_tests(basic_tests, module, loader):
242+ testmod_names = [
243+ 'test_repository',
244+ ]
245+ basic_tests.addTest(loader.loadTestsFromModuleNames(
246+ ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
247+ return basic_tests
248
249=== added file 'bzrlib/tests/per_repository_vf/test_repository.py'
250--- bzrlib/tests/per_repository_vf/test_repository.py 1970-01-01 00:00:00 +0000
251+++ bzrlib/tests/per_repository_vf/test_repository.py 2011-03-08 20:41:55 +0000
252@@ -0,0 +1,91 @@
253+# Copyright (C) 2011 Canonical Ltd
254+#
255+# This program is free software; you can redistribute it and/or modify
256+# it under the terms of the GNU General Public License as published by
257+# the Free Software Foundation; either version 2 of the License, or
258+# (at your option) any later version.
259+#
260+# This program is distributed in the hope that it will be useful,
261+# but WITHOUT ANY WARRANTY; without even the implied warranty of
262+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263+# GNU General Public License for more details.
264+#
265+# You should have received a copy of the GNU General Public License
266+# along with this program; if not, write to the Free Software
267+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
268+
269+"""Tests for repository implementations - tests a repository format."""
270+
271+from bzrlib import (
272+ versionedfile,
273+ )
274+
275+from bzrlib.tests.per_repository_vf import (
276+ TestCaseWithRepository,
277+ all_repository_vf_format_scenarios,
278+ )
279+from bzrlib.tests.scenarios import load_tests_apply_scenarios
280+
281+
282+load_tests = load_tests_apply_scenarios
283+
284+
285+class TestRepository(TestCaseWithRepository):
286+
287+ scenarios = all_repository_vf_format_scenarios()
288+
289+ def test_attribute_inventories_store(self):
290+ """Test the existence of the inventories attribute."""
291+ tree = self.make_branch_and_tree('tree')
292+ repo = tree.branch.repository
293+ self.assertIsInstance(repo.inventories, versionedfile.VersionedFiles)
294+
295+ def test_attribute_inventories_basics(self):
296+ """Test basic aspects of the inventories attribute."""
297+ tree = self.make_branch_and_tree('tree')
298+ repo = tree.branch.repository
299+ rev_id = (tree.commit('a'),)
300+ tree.lock_read()
301+ self.addCleanup(tree.unlock)
302+ self.assertEqual(set([rev_id]), set(repo.inventories.keys()))
303+
304+ def test_attribute_revision_store(self):
305+ """Test the existence of the revisions attribute."""
306+ tree = self.make_branch_and_tree('tree')
307+ repo = tree.branch.repository
308+ self.assertIsInstance(repo.revisions,
309+ versionedfile.VersionedFiles)
310+
311+ def test_attribute_revision_store_basics(self):
312+ """Test the basic behaviour of the revisions attribute."""
313+ tree = self.make_branch_and_tree('tree')
314+ repo = tree.branch.repository
315+ repo.lock_write()
316+ try:
317+ self.assertEqual(set(), set(repo.revisions.keys()))
318+ revid = (tree.commit("foo"),)
319+ self.assertEqual(set([revid]), set(repo.revisions.keys()))
320+ self.assertEqual({revid:()},
321+ repo.revisions.get_parent_map([revid]))
322+ finally:
323+ repo.unlock()
324+ tree2 = self.make_branch_and_tree('tree2')
325+ tree2.pull(tree.branch)
326+ left_id = (tree2.commit('left'),)
327+ right_id = (tree.commit('right'),)
328+ tree.merge_from_branch(tree2.branch)
329+ merge_id = (tree.commit('merged'),)
330+ repo.lock_read()
331+ self.addCleanup(repo.unlock)
332+ self.assertEqual(set([revid, left_id, right_id, merge_id]),
333+ set(repo.revisions.keys()))
334+ self.assertEqual({revid:(), left_id:(revid,), right_id:(revid,),
335+ merge_id:(right_id, left_id)},
336+ repo.revisions.get_parent_map(repo.revisions.keys()))
337+
338+ def test_attribute_signature_store(self):
339+ """Test the existence of the signatures attribute."""
340+ tree = self.make_branch_and_tree('tree')
341+ repo = tree.branch.repository
342+ self.assertIsInstance(repo.signatures,
343+ versionedfile.VersionedFiles)
344
345=== modified file 'doc/en/release-notes/bzr-2.4.txt'
346--- doc/en/release-notes/bzr-2.4.txt 2011-03-08 16:00:55 +0000
347+++ doc/en/release-notes/bzr-2.4.txt 2011-03-08 20:41:55 +0000
348@@ -186,6 +186,12 @@
349 (``bzrlib.repository.format_registry``) rather than using the class
350 methods on ``RepositoryFormat``. (Jelmer Vernooij)
351
352+* Repository formats can now indicate they do not support the full
353+ VersionedFiles API by setting the ``supports_full_versioned_files``
354+ attribute to False. A subset of the VersionedFiles API
355+ (signatures and text graphs) still needs to be supported.
356+ (Jelmer Vernooij)
357+
358 * Repository formats have a new method ``is_deprecated`` that
359 implementations can override to return True to trigger a deprecation
360 warning. (Jelmer Vernooij)