5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2006-2011 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
16 |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
17 |
"""Tests for repository implementations - tests a repository format."""
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
18 |
|
2520.4.54
by Aaron Bentley
Hang a create_bundle method off repository |
19 |
from cStringIO import StringIO |
1666.1.6
by Robert Collins
Make knit the default format. |
20 |
import re |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
21 |
|
1752.2.87
by Andrew Bennetts
Make tests pass. |
22 |
from bzrlib import ( |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
23 |
branch as _mod_branch, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
24 |
bzrdir, |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
25 |
delta as _mod_delta, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
26 |
errors, |
3735.2.100
by Vincent Ladeuil
Fix 3 failing tests due to an amazing typo. |
27 |
gpg, |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
28 |
info, |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
29 |
inventory, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
30 |
remote, |
31 |
repository, |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
32 |
revision as _mod_revision, |
33 |
tests, |
|
34 |
transport, |
|
35 |
upgrade, |
|
36 |
workingtree, |
|
1752.2.87
by Andrew Bennetts
Make tests pass. |
37 |
)
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
38 |
from bzrlib.repofmt import ( |
5757.1.5
by Jelmer Vernooij
Fix import. |
39 |
knitpack_repo, |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
40 |
)
|
5017.3.42
by Vincent Ladeuil
-s bt.per_repository.test_repo passing |
41 |
from bzrlib.tests import ( |
42 |
per_repository, |
|
43 |
test_server, |
|
44 |
)
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
45 |
from bzrlib.tests.matchers import * |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
46 |
|
47 |
||
48 |
class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository): |
|
2018.5.66
by Wouter van Heyst
Fix repository test parameterization for RemoteRepository. |
49 |
|
50 |
def test_repository_format(self): |
|
2018.5.119
by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree. |
51 |
# make sure the repository on tree.branch is of the desired format,
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
52 |
# because developers use this api to setup the tree, branch and
|
2018.5.119
by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree. |
53 |
# repository for their tests: having it now give the right repository
|
54 |
# type would invalidate the tests.
|
|
2018.5.66
by Wouter van Heyst
Fix repository test parameterization for RemoteRepository. |
55 |
tree = self.make_branch_and_tree('repo') |
56 |
self.assertIsInstance(tree.branch.repository._format, |
|
57 |
self.repository_format.__class__) |
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
58 |
|
59 |
||
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
60 |
class TestRepository(per_repository.TestCaseWithRepository): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
61 |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
62 |
def assertFormatAttribute(self, attribute, allowed_values): |
63 |
"""Assert that the format has an attribute 'attribute'."""
|
|
64 |
repo = self.make_repository('repo') |
|
65 |
self.assertSubset([getattr(repo._format, attribute)], allowed_values) |
|
66 |
||
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
67 |
def test_attribute_fast_deltas(self): |
68 |
"""Test the format.fast_deltas attribute."""
|
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
69 |
self.assertFormatAttribute('fast_deltas', (True, False)) |
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
70 |
|
6145.2.2
by Jelmer Vernooij
Set supports_nesting_repositories. |
71 |
def test_attribute_supports_nesting_repositories(self): |
72 |
"""Test the format.supports_nesting_repositories."""
|
|
73 |
self.assertFormatAttribute('supports_nesting_repositories', |
|
74 |
(True, False)) |
|
75 |
||
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
76 |
def test_attribute__fetch_reconcile(self): |
4775.1.1
by Martin Pool
Remove several 'the the' typos |
77 |
"""Test the _fetch_reconcile attribute."""
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
78 |
self.assertFormatAttribute('_fetch_reconcile', (True, False)) |
79 |
||
4988.9.1
by Jelmer Vernooij
Add experimental flag to RepositoryFormat. |
80 |
def test_attribute_format_experimental(self): |
81 |
self.assertFormatAttribute('experimental', (True, False)) |
|
82 |
||
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
83 |
def test_attribute_format_pack_compresses(self): |
84 |
self.assertFormatAttribute('pack_compresses', (True, False)) |
|
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
85 |
|
5684.2.1
by Jelmer Vernooij
Add bzrlib.tests.per_repository_vf. |
86 |
def test_attribute_format_supports_full_versioned_files(self): |
87 |
self.assertFormatAttribute('supports_full_versioned_files', |
|
88 |
(True, False)) |
|
89 |
||
90 |
def test_attribute_format_supports_funky_characters(self): |
|
91 |
self.assertFormatAttribute('supports_funky_characters', |
|
92 |
(True, False)) |
|
93 |
||
94 |
def test_attribute_format_supports_leaving_lock(self): |
|
95 |
self.assertFormatAttribute('supports_leaving_lock', |
|
96 |
(True, False)) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
97 |
|
5993.3.2
by Jelmer Vernooij
Add Repository.supports_versioned_directories. |
98 |
def test_attribute_format_versioned_directories(self): |
99 |
self.assertFormatAttribute('supports_versioned_directories', (True, False)) |
|
100 |
||
5766.1.1
by Jelmer Vernooij
Make revision-graph-can-have-wrong-parents a repository format attribute rather than a repository method. |
101 |
def test_attribute_format_revision_graph_can_have_wrong_parents(self): |
102 |
self.assertFormatAttribute('revision_graph_can_have_wrong_parents', |
|
103 |
(True, False)) |
|
104 |
||
5675.2.5
by Jelmer Vernooij
add tests for repository attributes. |
105 |
def test_format_is_deprecated(self): |
106 |
repo = self.make_repository('repo') |
|
5675.2.6
by Jelmer Vernooij
Fix some tests. |
107 |
self.assertSubset([repo._format.is_deprecated()], (True, False)) |
5675.2.5
by Jelmer Vernooij
add tests for repository attributes. |
108 |
|
109 |
def test_format_is_supported(self): |
|
110 |
repo = self.make_repository('repo') |
|
5675.2.6
by Jelmer Vernooij
Fix some tests. |
111 |
self.assertSubset([repo._format.is_supported()], (True, False)) |
5675.2.5
by Jelmer Vernooij
add tests for repository attributes. |
112 |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
113 |
def test_clone_to_default_format(self): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
114 |
#TODO: Test that cloning a repository preserves all the information
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
115 |
# such as signatures[not tested yet] etc etc.
|
116 |
# when changing to the current default format.
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
117 |
tree_a = self.make_branch_and_tree('a') |
2381.1.3
by Robert Collins
Review feedback. |
118 |
self.build_tree(['a/foo']) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
119 |
tree_a.add('foo', 'file1') |
120 |
tree_a.commit('rev1', rev_id='rev1') |
|
121 |
bzrdirb = self.make_bzrdir('b') |
|
122 |
repo_b = tree_a.branch.repository.clone(bzrdirb) |
|
123 |
tree_b = repo_b.revision_tree('rev1') |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
124 |
tree_b.lock_read() |
125 |
self.addCleanup(tree_b.unlock) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
126 |
tree_b.get_file_text('file1') |
127 |
rev1 = repo_b.get_revision('rev1') |
|
128 |
||
1910.2.63
by Aaron Bentley
Add supports_rich_root member to repository |
129 |
def test_supports_rich_root(self): |
130 |
tree = self.make_branch_and_tree('a') |
|
131 |
tree.commit('') |
|
132 |
second_revision = tree.commit('') |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
133 |
rev_tree = tree.branch.repository.revision_tree(second_revision) |
134 |
rev_tree.lock_read() |
|
135 |
self.addCleanup(rev_tree.unlock) |
|
5805.1.1
by Jelmer Vernooij
Avoid using inventories in some tests. |
136 |
root_revision = rev_tree.get_file_revision(rev_tree.get_root_id()) |
137 |
rich_root = (root_revision != second_revision) |
|
2018.5.113
by Robert Collins
Test only fixes from the ported-to-bzr.dev test-correctness branch. |
138 |
self.assertEqual(rich_root, |
1910.2.63
by Aaron Bentley
Add supports_rich_root member to repository |
139 |
tree.branch.repository.supports_rich_root()) |
140 |
||
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
141 |
def test_clone_specific_format(self): |
142 |
"""todo"""
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
143 |
|
144 |
def test_format_initialize_find_open(self): |
|
145 |
# loopback test to check the current format initializes to itself.
|
|
146 |
if not self.repository_format.is_supported(): |
|
147 |
# unsupported formats are not loopback testable
|
|
148 |
# because the default open will not open them and
|
|
149 |
# they may not be initializable.
|
|
150 |
return
|
|
151 |
# supported formats must be able to init and open
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
152 |
t = self.get_transport() |
153 |
readonly_t = self.get_readonly_transport() |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
154 |
made_control = self.bzrdir_format.initialize(t.base) |
155 |
made_repo = self.repository_format.initialize(made_control) |
|
156 |
self.assertEqual(made_control, made_repo.bzrdir) |
|
157 |
||
158 |
# find it via bzrdir opening:
|
|
159 |
opened_control = bzrdir.BzrDir.open(readonly_t.base) |
|
160 |
direct_opened_repo = opened_control.open_repository() |
|
161 |
self.assertEqual(direct_opened_repo.__class__, made_repo.__class__) |
|
162 |
self.assertEqual(opened_control, direct_opened_repo.bzrdir) |
|
163 |
||
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
164 |
self.assertIsInstance(direct_opened_repo._format, |
165 |
self.repository_format.__class__) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
166 |
# find it via Repository.open
|
167 |
opened_repo = repository.Repository.open(readonly_t.base) |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
168 |
self.assertIsInstance(opened_repo, made_repo.__class__) |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
169 |
self.assertEqual(made_repo._format.__class__, |
170 |
opened_repo._format.__class__) |
|
171 |
# if it has a unique id string, can we probe for it ?
|
|
172 |
try: |
|
173 |
self.repository_format.get_format_string() |
|
174 |
except NotImplementedError: |
|
175 |
return
|
|
176 |
self.assertEqual(self.repository_format, |
|
177 |
repository.RepositoryFormat.find_format(opened_control)) |
|
178 |
||
3845.1.1
by John Arbash Meinel
Ensure that RepositoryFormat._matchingbzrdir.repository_format matches. |
179 |
def test_format_matchingbzrdir(self): |
180 |
self.assertEqual(self.repository_format, |
|
181 |
self.repository_format._matchingbzrdir.repository_format) |
|
182 |
self.assertEqual(self.repository_format, |
|
183 |
self.bzrdir_format.repository_format) |
|
184 |
||
3990.5.1
by Andrew Bennetts
Add network_name() to RepositoryFormat. |
185 |
def test_format_network_name(self): |
186 |
repo = self.make_repository('r') |
|
187 |
format = repo._format |
|
188 |
network_name = format.network_name() |
|
189 |
self.assertIsInstance(network_name, str) |
|
190 |
# We want to test that the network_name matches the actual format on
|
|
191 |
# disk. For local repositories, that means that using network_name as
|
|
192 |
# a key in the registry gives back the same format. For remote
|
|
193 |
# repositories, that means that the network_name of the
|
|
194 |
# RemoteRepositoryFormat we have locally matches the actual format
|
|
195 |
# present on the remote side.
|
|
196 |
if isinstance(format, remote.RemoteRepositoryFormat): |
|
197 |
repo._ensure_real() |
|
198 |
real_repo = repo._real_repository |
|
199 |
self.assertEqual(real_repo._format.network_name(), network_name) |
|
200 |
else: |
|
201 |
registry = repository.network_format_registry |
|
202 |
looked_up_format = registry.get(network_name) |
|
203 |
self.assertEqual(format.__class__, looked_up_format.__class__) |
|
204 |
||
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
205 |
def test_create_repository(self): |
1534.6.1
by Robert Collins
allow API creation of shared repositories |
206 |
# bzrdir can construct a repository for itself.
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
207 |
if not self.bzrdir_format.is_supported(): |
208 |
# unsupported formats are not loopback testable
|
|
209 |
# because the default open will not open them and
|
|
210 |
# they may not be initializable.
|
|
211 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
212 |
t = self.get_transport() |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
213 |
made_control = self.bzrdir_format.initialize(t.base) |
214 |
made_repo = made_control.create_repository() |
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
215 |
# Check that we have a repository object.
|
216 |
made_repo.has_revision('foo') |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
217 |
self.assertEqual(made_control, made_repo.bzrdir) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
218 |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
219 |
def test_create_repository_shared(self): |
220 |
# bzrdir can construct a shared repository.
|
|
221 |
if not self.bzrdir_format.is_supported(): |
|
222 |
# unsupported formats are not loopback testable
|
|
223 |
# because the default open will not open them and
|
|
224 |
# they may not be initializable.
|
|
225 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
226 |
t = self.get_transport() |
1534.6.1
by Robert Collins
allow API creation of shared repositories |
227 |
made_control = self.bzrdir_format.initialize(t.base) |
228 |
try: |
|
229 |
made_repo = made_control.create_repository(shared=True) |
|
230 |
except errors.IncompatibleFormat: |
|
231 |
# not all repository formats understand being shared, or
|
|
232 |
# may only be shared in some circumstances.
|
|
233 |
return
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
234 |
# Check that we have a repository object.
|
235 |
made_repo.has_revision('foo') |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
236 |
self.assertEqual(made_control, made_repo.bzrdir) |
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
237 |
self.assertTrue(made_repo.is_shared()) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
238 |
|
239 |
def test_revision_tree(self): |
|
240 |
wt = self.make_branch_and_tree('.') |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
241 |
wt.set_root_id('fixed-root') |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
242 |
wt.commit('lala!', rev_id='revision-1', allow_pointless=True) |
243 |
tree = wt.branch.repository.revision_tree('revision-1') |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
244 |
tree.lock_read() |
245 |
try: |
|
5819.2.5
by Jelmer Vernooij
Use tree methods rather than inventory methods. |
246 |
self.assertEqual('revision-1', |
247 |
tree.get_file_revision(tree.get_root_id())) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
248 |
expected = inventory.InventoryDirectory('fixed-root', '', None) |
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
249 |
expected.revision = 'revision-1' |
250 |
self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)], |
|
251 |
list(tree.list_files(include_root=True))) |
|
252 |
finally: |
|
253 |
tree.unlock() |
|
3668.5.3
by Jelmer Vernooij
Add test to make sure revision_tree(None) prints a deprecation warning. |
254 |
tree = self.callDeprecated(['NULL_REVISION should be used for the null' |
255 |
' revision instead of None, as of bzr 0.91.'], |
|
256 |
wt.branch.repository.revision_tree, None) |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
257 |
tree.lock_read() |
258 |
try: |
|
259 |
self.assertEqual([], list(tree.list_files(include_root=True))) |
|
260 |
finally: |
|
261 |
tree.unlock() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
262 |
tree = wt.branch.repository.revision_tree(_mod_revision.NULL_REVISION) |
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
263 |
tree.lock_read() |
264 |
try: |
|
265 |
self.assertEqual([], list(tree.list_files(include_root=True))) |
|
266 |
finally: |
|
267 |
tree.unlock() |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
268 |
|
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
269 |
def test_get_revision_delta(self): |
270 |
tree_a = self.make_branch_and_tree('a') |
|
2381.1.3
by Robert Collins
Review feedback. |
271 |
self.build_tree(['a/foo']) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
272 |
tree_a.add('foo', 'file1') |
273 |
tree_a.commit('rev1', rev_id='rev1') |
|
2381.1.3
by Robert Collins
Review feedback. |
274 |
self.build_tree(['a/vla']) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
275 |
tree_a.add('vla', 'file2') |
276 |
tree_a.commit('rev2', rev_id='rev2') |
|
277 |
||
278 |
delta = tree_a.branch.repository.get_revision_delta('rev1') |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
279 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
280 |
self.assertEqual([('foo', 'file1', 'file')], delta.added) |
281 |
delta = tree_a.branch.repository.get_revision_delta('rev2') |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
282 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
283 |
self.assertEqual([('vla', 'file2', 'file')], delta.added) |
284 |
||
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
285 |
def test_get_revision_delta_filtered(self): |
286 |
tree_a = self.make_branch_and_tree('a') |
|
287 |
self.build_tree(['a/foo', 'a/bar/', 'a/bar/b1', 'a/bar/b2', 'a/baz']) |
|
288 |
tree_a.add(['foo', 'bar', 'bar/b1', 'bar/b2', 'baz'], |
|
289 |
['foo-id', 'bar-id', 'b1-id', 'b2-id', 'baz-id']) |
|
290 |
tree_a.commit('rev1', rev_id='rev1') |
|
291 |
self.build_tree(['a/bar/b3']) |
|
292 |
tree_a.add('bar/b3', 'b3-id') |
|
293 |
tree_a.commit('rev2', rev_id='rev2') |
|
294 |
||
295 |
# Test multiple files
|
|
296 |
delta = tree_a.branch.repository.get_revision_delta('rev1', |
|
297 |
specific_fileids=['foo-id', 'baz-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
298 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
299 |
self.assertEqual([ |
300 |
('baz', 'baz-id', 'file'), |
|
301 |
('foo', 'foo-id', 'file'), |
|
302 |
], delta.added) |
|
303 |
# Test a directory
|
|
304 |
delta = tree_a.branch.repository.get_revision_delta('rev1', |
|
305 |
specific_fileids=['bar-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
306 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
307 |
self.assertEqual([ |
308 |
('bar', 'bar-id', 'directory'), |
|
309 |
('bar/b1', 'b1-id', 'file'), |
|
310 |
('bar/b2', 'b2-id', 'file'), |
|
311 |
], delta.added) |
|
312 |
# Test a file in a directory
|
|
313 |
delta = tree_a.branch.repository.get_revision_delta('rev1', |
|
314 |
specific_fileids=['b2-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
315 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
316 |
self.assertEqual([ |
317 |
('bar', 'bar-id', 'directory'), |
|
318 |
('bar/b2', 'b2-id', 'file'), |
|
319 |
], delta.added) |
|
320 |
# Try another revision
|
|
321 |
delta = tree_a.branch.repository.get_revision_delta('rev2', |
|
322 |
specific_fileids=['b3-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
323 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
324 |
self.assertEqual([ |
325 |
('bar', 'bar-id', 'directory'), |
|
326 |
('bar/b3', 'b3-id', 'file'), |
|
327 |
], delta.added) |
|
328 |
delta = tree_a.branch.repository.get_revision_delta('rev2', |
|
329 |
specific_fileids=['foo-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
330 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
331 |
self.assertEqual([], delta.added) |
332 |
||
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
333 |
def test_clone_bzrdir_repository_revision(self): |
334 |
# make a repository with some revisions,
|
|
335 |
# and clone it, this should not have unreferenced revisions.
|
|
336 |
# also: test cloning with a revision id of NULL_REVISION -> empty repo.
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
337 |
raise tests.TestSkipped('revision limiting is not implemented yet.') |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
338 |
|
339 |
def test_clone_repository_basis_revision(self): |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
340 |
raise tests.TestSkipped( |
341 |
'the use of a basis should not add noise data to the result.') |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
342 |
|
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
343 |
def test_clone_shared_no_tree(self): |
344 |
# cloning a shared repository keeps it shared
|
|
345 |
# and preserves the make_working_tree setting.
|
|
346 |
made_control = self.make_bzrdir('source') |
|
347 |
try: |
|
348 |
made_repo = made_control.create_repository(shared=True) |
|
349 |
except errors.IncompatibleFormat: |
|
350 |
# not all repository formats understand being shared, or
|
|
351 |
# may only be shared in some circumstances.
|
|
352 |
return
|
|
2018.14.2
by Andrew Bennetts
All but one repository_implementation tests for RemoteRepository passing. |
353 |
try: |
354 |
made_repo.set_make_working_trees(False) |
|
6104.2.2
by Jelmer Vernooij
Expect UnsupportedOperation when set_make_working_trees is not available. |
355 |
except errors.UnsupportedOperation: |
2018.5.120
by Robert Collins
The Repository API ``make_working_trees`` is now permitted to return |
356 |
# the repository does not support having its tree-making flag
|
357 |
# toggled.
|
|
358 |
return
|
|
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
359 |
result = made_control.clone(self.get_url('target')) |
1752.2.55
by Andrew Bennetts
Replace another isinstance(made_repo, Repository) check. |
360 |
# Check that we have a repository object.
|
361 |
made_repo.has_revision('foo') |
|
362 |
||
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
363 |
self.assertEqual(made_control, made_repo.bzrdir) |
364 |
self.assertTrue(result.open_repository().is_shared()) |
|
365 |
self.assertFalse(result.open_repository().make_working_trees()) |
|
366 |
||
2018.5.90
by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository. |
367 |
def test_upgrade_preserves_signatures(self): |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
368 |
wt = self.make_branch_and_tree('source') |
369 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
2018.5.90
by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository. |
370 |
repo = wt.branch.repository |
2592.3.39
by Robert Collins
Fugly version to remove signatures.kndx |
371 |
repo.lock_write() |
372 |
repo.start_write_group() |
|
5751.2.3
by Jelmer Vernooij
More tests |
373 |
try: |
374 |
repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) |
|
375 |
except errors.UnsupportedOperation: |
|
376 |
self.assertFalse(repo._format.supports_revision_signatures) |
|
6113.1.2
by Jelmer Vernooij
Fix an import. |
377 |
raise tests.TestNotApplicable("signatures not supported by repository format") |
2592.3.39
by Robert Collins
Fugly version to remove signatures.kndx |
378 |
repo.commit_write_group() |
379 |
repo.unlock() |
|
2018.5.90
by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository. |
380 |
old_signature = repo.get_signature_text('A') |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
381 |
try: |
382 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
383 |
# This gives metadir branches something they can convert to.
|
|
384 |
# it would be nice to have a 'latest' vs 'default' concept.
|
|
2255.2.208
by Robert Collins
Remove more references to 'experimental' formats. |
385 |
format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree') |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
386 |
upgrade.upgrade(repo.bzrdir.root_transport.base, format=format) |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
387 |
except errors.UpToDateFormat: |
388 |
# this is in the most current format already.
|
|
389 |
return
|
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
390 |
except errors.BadConversionTarget, e: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
391 |
raise tests.TestSkipped(str(e)) |
392 |
wt = workingtree.WorkingTree.open(wt.basedir) |
|
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
393 |
new_signature = wt.branch.repository.get_signature_text('A') |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
394 |
self.assertEqual(old_signature, new_signature) |
395 |
||
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
396 |
def test_format_description(self): |
397 |
repo = self.make_repository('.') |
|
398 |
text = repo._format.get_format_description() |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
399 |
self.assertTrue(len(text)) |
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
400 |
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
401 |
def test_format_supports_external_lookups(self): |
402 |
repo = self.make_repository('.') |
|
403 |
self.assertSubset( |
|
404 |
[repo._format.supports_external_lookups], (True, False)) |
|
405 |
||
1666.1.6
by Robert Collins
Make knit the default format. |
406 |
def assertMessageRoundtrips(self, message): |
407 |
"""Assert that message roundtrips to a repository and back intact."""
|
|
408 |
tree = self.make_branch_and_tree('.') |
|
409 |
tree.commit(message, rev_id='a', allow_pointless=True) |
|
410 |
rev = tree.branch.repository.get_revision('a') |
|
5815.4.13
by Jelmer Vernooij
Move corruption tests to bt.per_repository_vf. |
411 |
serializer = getattr(tree.branch.repository, "_serializer", None) |
412 |
if serializer is not None and serializer.squashes_xml_invalid_characters: |
|
4416.5.1
by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer. |
413 |
# we have to manually escape this as we dont try to
|
4443.1.2
by Jelmer Vernooij
Fix comment about XML escaping in tests. |
414 |
# roundtrip xml invalid characters in the xml-based serializers.
|
4416.5.1
by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer. |
415 |
escaped_message, escape_count = re.subn( |
416 |
u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+', |
|
417 |
lambda match: match.group(0).encode('unicode_escape'), |
|
418 |
message) |
|
419 |
self.assertEqual(rev.message, escaped_message) |
|
420 |
else: |
|
421 |
self.assertEqual(rev.message, message) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
422 |
# insist the class is unicode no matter what came in for
|
1666.1.6
by Robert Collins
Make knit the default format. |
423 |
# consistency.
|
424 |
self.assertIsInstance(rev.message, unicode) |
|
425 |
||
426 |
def test_commit_unicode_message(self): |
|
427 |
# a siple unicode message should be preserved
|
|
428 |
self.assertMessageRoundtrips(u'foo bar gamm\xae plop') |
|
429 |
||
430 |
def test_commit_unicode_control_characters(self): |
|
431 |
# a unicode message with control characters should roundtrip too.
|
|
3831.1.4
by John Arbash Meinel
Update the per-repository unicode commit test. |
432 |
unichars = [unichr(x) for x in range(256)] |
433 |
# '\r' is not directly allowed anymore, as it used to be translated
|
|
434 |
# into '\n' anyway
|
|
435 |
unichars[ord('\r')] = u'\n' |
|
1666.1.6
by Robert Collins
Make knit the default format. |
436 |
self.assertMessageRoundtrips( |
3831.1.4
by John Arbash Meinel
Update the per-repository unicode commit test. |
437 |
u"All 8-bit chars: " + ''.join(unichars)) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
438 |
|
1732.2.4
by Martin Pool
Split check into Branch.check and Repository.check |
439 |
def test_check_repository(self): |
440 |
"""Check a fairly simple repository's history"""
|
|
441 |
tree = self.make_branch_and_tree('.') |
|
442 |
tree.commit('initial empty commit', rev_id='a-rev', |
|
443 |
allow_pointless=True) |
|
2745.6.39
by Andrew Bennetts
Use scenario in test_check too, and make check actually report inconsistent parents to the end user. |
444 |
result = tree.branch.repository.check() |
1732.2.4
by Martin Pool
Split check into Branch.check and Repository.check |
445 |
# writes to log; should accept both verbose or non-verbose
|
446 |
result.report_results(verbose=True) |
|
447 |
result.report_results(verbose=False) |
|
448 |
||
1756.1.5
by Aaron Bentley
Test get_revisions with all repository types (and fix bug...) |
449 |
def test_get_revisions(self): |
450 |
tree = self.make_branch_and_tree('.') |
|
451 |
tree.commit('initial empty commit', rev_id='a-rev', |
|
452 |
allow_pointless=True) |
|
453 |
tree.commit('second empty commit', rev_id='b-rev', |
|
454 |
allow_pointless=True) |
|
455 |
tree.commit('third empty commit', rev_id='c-rev', |
|
456 |
allow_pointless=True) |
|
457 |
repo = tree.branch.repository |
|
458 |
revision_ids = ['a-rev', 'b-rev', 'c-rev'] |
|
459 |
revisions = repo.get_revisions(revision_ids) |
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
460 |
self.assertEqual(len(revisions), 3) |
1756.1.5
by Aaron Bentley
Test get_revisions with all repository types (and fix bug...) |
461 |
zipped = zip(revisions, revision_ids) |
462 |
self.assertEqual(len(zipped), 3) |
|
463 |
for revision, revision_id in zipped: |
|
464 |
self.assertEqual(revision.revision_id, revision_id) |
|
465 |
self.assertEqual(revision, repo.get_revision(revision_id)) |
|
1732.2.4
by Martin Pool
Split check into Branch.check and Repository.check |
466 |
|
1910.2.1
by Aaron Bentley
Ensure root entry always has a revision |
467 |
def test_root_entry_has_revision(self): |
468 |
tree = self.make_branch_and_tree('.') |
|
469 |
tree.commit('message', rev_id='rev_id') |
|
2255.7.65
by Robert Collins
Split test_root_revision_entry into tree and repository portions. |
470 |
rev_tree = tree.branch.repository.revision_tree(tree.last_revision()) |
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
471 |
rev_tree.lock_read() |
472 |
self.addCleanup(rev_tree.unlock) |
|
5805.1.1
by Jelmer Vernooij
Avoid using inventories in some tests. |
473 |
root_id = rev_tree.get_root_id() |
474 |
self.assertEqual('rev_id', rev_tree.get_file_revision(root_id)) |
|
1910.2.36
by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats |
475 |
|
1910.2.37
by Aaron Bentley
Handle empty commits, fix test |
476 |
def test_pointless_commit(self): |
477 |
tree = self.make_branch_and_tree('.') |
|
478 |
self.assertRaises(errors.PointlessCommit, tree.commit, 'pointless', |
|
479 |
allow_pointless=False) |
|
480 |
tree.commit('pointless', allow_pointless=True) |
|
481 |
||
2323.5.17
by Martin Pool
Add supports_tree_reference to all repo formats (robert) |
482 |
def test_format_attributes(self): |
483 |
"""All repository formats should have some basic attributes."""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
484 |
# create a repository to get a real format instance, not the
|
3128.1.3
by Vincent Ladeuil
Since we are there s/parameteris.*/parameteriz&/. |
485 |
# template from the test suite parameterization.
|
2323.5.17
by Martin Pool
Add supports_tree_reference to all repo formats (robert) |
486 |
repo = self.make_repository('.') |
487 |
repo._format.rich_root_data |
|
488 |
repo._format.supports_tree_reference |
|
489 |
||
2708.1.7
by Aaron Bentley
Rename extract_files_bytes to iter_files_bytes |
490 |
def test_iter_files_bytes(self): |
2708.1.3
by Aaron Bentley
Implement extract_files_bytes on Repository |
491 |
tree = self.make_branch_and_tree('tree') |
492 |
self.build_tree_contents([('tree/file1', 'foo'), |
|
493 |
('tree/file2', 'bar')]) |
|
494 |
tree.add(['file1', 'file2'], ['file1-id', 'file2-id']) |
|
495 |
tree.commit('rev1', rev_id='rev1') |
|
496 |
self.build_tree_contents([('tree/file1', 'baz')]) |
|
497 |
tree.commit('rev2', rev_id='rev2') |
|
2708.1.11
by Aaron Bentley
Test and tweak error handling |
498 |
repository = tree.branch.repository |
2592.3.214
by Robert Collins
Merge bzr.dev. |
499 |
repository.lock_read() |
500 |
self.addCleanup(repository.unlock) |
|
2708.1.6
by Aaron Bentley
Turn extract_files_bytes into an iterator |
501 |
extracted = dict((i, ''.join(b)) for i, b in |
2708.1.11
by Aaron Bentley
Test and tweak error handling |
502 |
repository.iter_files_bytes( |
2708.1.6
by Aaron Bentley
Turn extract_files_bytes into an iterator |
503 |
[('file1-id', 'rev1', 'file1-old'), |
504 |
('file1-id', 'rev2', 'file1-new'), |
|
505 |
('file2-id', 'rev1', 'file2'), |
|
506 |
]))
|
|
507 |
self.assertEqual('foo', extracted['file1-old']) |
|
508 |
self.assertEqual('bar', extracted['file2']) |
|
509 |
self.assertEqual('baz', extracted['file1-new']) |
|
2708.1.11
by Aaron Bentley
Test and tweak error handling |
510 |
self.assertRaises(errors.RevisionNotPresent, list, |
511 |
repository.iter_files_bytes( |
|
512 |
[('file1-id', 'rev3', 'file1-notpresent')])) |
|
2592.3.102
by Robert Collins
Change the iter_files_bytes error to allow either RevisionNotPresent or NoSuchId when requesting a file that was not in the repository at all. |
513 |
self.assertRaises((errors.RevisionNotPresent, errors.NoSuchId), list, |
2708.1.11
by Aaron Bentley
Test and tweak error handling |
514 |
repository.iter_files_bytes( |
515 |
[('file3-id', 'rev3', 'file1-notpresent')])) |
|
2708.1.3
by Aaron Bentley
Implement extract_files_bytes on Repository |
516 |
|
2850.4.1
by Andrew Bennetts
Add smoketest for repo.get_graph, and fix bug in RemoteRepository.get_graph that it reveals. |
517 |
def test_get_graph(self): |
518 |
"""Bare-bones smoketest that all repositories implement get_graph."""
|
|
519 |
repo = self.make_repository('repo') |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
520 |
repo.lock_read() |
521 |
self.addCleanup(repo.unlock) |
|
2850.4.1
by Andrew Bennetts
Add smoketest for repo.get_graph, and fix bug in RemoteRepository.get_graph that it reveals. |
522 |
repo.get_graph() |
523 |
||
3146.1.1
by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider |
524 |
def test_graph_ghost_handling(self): |
525 |
tree = self.make_branch_and_tree('here') |
|
526 |
tree.lock_write() |
|
527 |
self.addCleanup(tree.unlock) |
|
528 |
tree.commit('initial commit', rev_id='rev1') |
|
529 |
tree.add_parent_tree_id('ghost') |
|
530 |
tree.commit('commit-with-ghost', rev_id='rev2') |
|
531 |
graph = tree.branch.repository.get_graph() |
|
532 |
parents = graph.get_parent_map(['ghost', 'rev2']) |
|
533 |
self.assertTrue('ghost' not in parents) |
|
3146.1.2
by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists |
534 |
self.assertEqual(parents['rev2'], ('rev1', 'ghost')) |
535 |
||
4913.4.4
by Jelmer Vernooij
Add test for Repository.get_known_graph_ancestry(). |
536 |
def test_get_known_graph_ancestry(self): |
537 |
tree = self.make_branch_and_tree('here') |
|
538 |
tree.lock_write() |
|
539 |
self.addCleanup(tree.unlock) |
|
540 |
# A
|
|
541 |
# |\
|
|
542 |
# | B
|
|
543 |
# |/
|
|
544 |
# C
|
|
545 |
tree.commit('initial commit', rev_id='A') |
|
546 |
tree_other = tree.bzrdir.sprout('there').open_workingtree() |
|
547 |
tree_other.commit('another', rev_id='B') |
|
548 |
tree.merge_from_branch(tree_other.branch) |
|
549 |
tree.commit('another', rev_id='C') |
|
550 |
kg = tree.branch.repository.get_known_graph_ancestry( |
|
551 |
['C']) |
|
552 |
self.assertEqual(['C'], list(kg.heads(['A', 'B', 'C']))) |
|
553 |
self.assertEqual(['A', 'B', 'C'], list(kg.topo_sort())) |
|
554 |
||
3146.1.2
by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists |
555 |
def test_parent_map_type(self): |
556 |
tree = self.make_branch_and_tree('here') |
|
557 |
tree.lock_write() |
|
558 |
self.addCleanup(tree.unlock) |
|
559 |
tree.commit('initial commit', rev_id='rev1') |
|
560 |
tree.commit('next commit', rev_id='rev2') |
|
561 |
graph = tree.branch.repository.get_graph() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
562 |
parents = graph.get_parent_map( |
563 |
[_mod_revision.NULL_REVISION, 'rev1', 'rev2']) |
|
3146.1.2
by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists |
564 |
for value in parents.values(): |
565 |
self.assertIsInstance(value, tuple) |
|
3146.1.1
by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider |
566 |
|
2819.2.4
by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository. |
567 |
def test_implements_revision_graph_can_have_wrong_parents(self): |
568 |
"""All repositories should implement
|
|
569 |
revision_graph_can_have_wrong_parents, so that check and reconcile can
|
|
570 |
work correctly.
|
|
571 |
"""
|
|
572 |
repo = self.make_repository('.') |
|
573 |
# This should work, not raise NotImplementedError:
|
|
5766.1.2
by Jelmer Vernooij
Fix two more references to old method. |
574 |
if not repo._format.revision_graph_can_have_wrong_parents: |
2592.3.214
by Robert Collins
Merge bzr.dev. |
575 |
return
|
576 |
repo.lock_read() |
|
577 |
self.addCleanup(repo.unlock) |
|
578 |
# This repo must also implement
|
|
579 |
# _find_inconsistent_revision_parents and
|
|
580 |
# _check_for_inconsistent_revision_parents. So calling these
|
|
581 |
# should not raise NotImplementedError.
|
|
582 |
list(repo._find_inconsistent_revision_parents()) |
|
583 |
repo._check_for_inconsistent_revision_parents() |
|
2819.2.4
by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository. |
584 |
|
2996.2.4
by Aaron Bentley
Rename function to add_signature_text |
585 |
def test_add_signature_text(self): |
5751.2.1
by Jelmer Vernooij
Add RepositoryFormat.supports_revision_signatures. |
586 |
builder = self.make_branch_builder('.') |
587 |
builder.start_series() |
|
588 |
builder.build_snapshot('A', None, [ |
|
589 |
('add', ('', 'root-id', 'directory', None))]) |
|
5751.2.2
by Jelmer Vernooij
Fix tests. |
590 |
builder.finish_series() |
5751.2.1
by Jelmer Vernooij
Add RepositoryFormat.supports_revision_signatures. |
591 |
b = builder.get_branch() |
5751.2.2
by Jelmer Vernooij
Fix tests. |
592 |
b.lock_write() |
5751.2.4
by Jelmer Vernooij
Use addCleanup to call abort_write_group rather than try/finally. |
593 |
self.addCleanup(b.unlock) |
5751.2.2
by Jelmer Vernooij
Fix tests. |
594 |
b.repository.start_write_group() |
5751.2.4
by Jelmer Vernooij
Use addCleanup to call abort_write_group rather than try/finally. |
595 |
self.addCleanup(b.repository.abort_write_group) |
596 |
if b.repository._format.supports_revision_signatures: |
|
597 |
b.repository.add_signature_text('A', 'This might be a signature') |
|
598 |
self.assertEqual('This might be a signature', |
|
599 |
b.repository.get_signature_text('A')) |
|
600 |
else: |
|
601 |
self.assertRaises(errors.UnsupportedOperation, |
|
602 |
b.repository.add_signature_text, 'A', |
|
603 |
'This might be a signature') |
|
2996.2.3
by Aaron Bentley
Add tests for install_revisions and add_signature |
604 |
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
605 |
# XXX: this helper duplicated from tests.test_repository
|
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
606 |
def make_remote_repository(self, path, shared=False): |
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
607 |
"""Make a RemoteRepository object backed by a real repository that will
|
608 |
be created at the given path."""
|
|
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
609 |
repo = self.make_repository(path, shared=shared) |
5017.3.42
by Vincent Ladeuil
-s bt.per_repository.test_repo passing |
610 |
smart_server = test_server.SmartTCPServer_for_testing() |
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
611 |
self.start_server(smart_server, self.get_server()) |
6083.1.1
by Jelmer Vernooij
Use get_transport_from_{url,path} in more places. |
612 |
remote_transport = transport.get_transport_from_url( |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
613 |
smart_server.get_url()).clone(path) |
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
614 |
remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport) |
615 |
remote_repo = remote_bzrdir.open_repository() |
|
616 |
return remote_repo |
|
617 |
||
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
618 |
def test_sprout_from_hpss_preserves_format(self): |
619 |
"""repo.sprout from a smart server preserves the repository format."""
|
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
620 |
remote_repo = self.make_remote_repository('remote') |
621 |
local_bzrdir = self.make_bzrdir('local') |
|
622 |
try: |
|
623 |
local_repo = remote_repo.sprout(local_bzrdir) |
|
624 |
except errors.TransportNotPossible: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
625 |
raise tests.TestNotApplicable( |
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
626 |
"Cannot lock_read old formats like AllInOne over HPSS.") |
627 |
remote_backing_repo = bzrdir.BzrDir.open( |
|
628 |
self.get_vfs_only_url('remote')).open_repository() |
|
629 |
self.assertEqual(remote_backing_repo._format, local_repo._format) |
|
630 |
||
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
631 |
def test_sprout_branch_from_hpss_preserves_repo_format(self): |
632 |
"""branch.sprout from a smart server preserves the repository format.
|
|
633 |
"""
|
|
5674.1.1
by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat. |
634 |
if not self.repository_format.supports_leaving_lock: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
635 |
raise tests.TestNotApplicable( |
5674.1.1
by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat. |
636 |
"Format can not be used over HPSS") |
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
637 |
remote_repo = self.make_remote_repository('remote') |
638 |
remote_branch = remote_repo.bzrdir.create_branch() |
|
639 |
try: |
|
640 |
local_bzrdir = remote_branch.bzrdir.sprout('local') |
|
641 |
except errors.TransportNotPossible: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
642 |
raise tests.TestNotApplicable( |
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
643 |
"Cannot lock_read old formats like AllInOne over HPSS.") |
644 |
local_repo = local_bzrdir.open_repository() |
|
645 |
remote_backing_repo = bzrdir.BzrDir.open( |
|
646 |
self.get_vfs_only_url('remote')).open_repository() |
|
647 |
self.assertEqual(remote_backing_repo._format, local_repo._format) |
|
648 |
||
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
649 |
def test_sprout_branch_from_hpss_preserves_shared_repo_format(self): |
650 |
"""branch.sprout from a smart server preserves the repository format of
|
|
651 |
a branch from a shared repository.
|
|
652 |
"""
|
|
5674.1.1
by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat. |
653 |
if not self.repository_format.supports_leaving_lock: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
654 |
raise tests.TestNotApplicable( |
5674.1.1
by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat. |
655 |
"Format can not be used over HPSS") |
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
656 |
# Make a shared repo
|
657 |
remote_repo = self.make_remote_repository('remote', shared=True) |
|
658 |
remote_backing_repo = bzrdir.BzrDir.open( |
|
659 |
self.get_vfs_only_url('remote')).open_repository() |
|
660 |
# Make a branch in that repo in an old format that isn't the default
|
|
661 |
# branch format for the repo.
|
|
662 |
from bzrlib.branch import BzrBranchFormat5 |
|
663 |
format = remote_backing_repo.bzrdir.cloning_metadir() |
|
664 |
format._branch_format = BzrBranchFormat5() |
|
665 |
remote_transport = remote_repo.bzrdir.root_transport.clone('branch') |
|
666 |
remote_backing_repo.bzrdir.create_branch_convenience( |
|
667 |
remote_transport.base, force_new_repo=False, format=format) |
|
668 |
remote_branch = bzrdir.BzrDir.open_from_transport( |
|
669 |
remote_transport).open_branch() |
|
670 |
try: |
|
671 |
local_bzrdir = remote_branch.bzrdir.sprout('local') |
|
672 |
except errors.TransportNotPossible: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
673 |
raise tests.TestNotApplicable( |
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
674 |
"Cannot lock_read old formats like AllInOne over HPSS.") |
675 |
local_repo = local_bzrdir.open_repository() |
|
676 |
self.assertEqual(remote_backing_repo._format, local_repo._format) |
|
677 |
||
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
678 |
def test_clone_to_hpss(self): |
5674.1.1
by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat. |
679 |
if not self.repository_format.supports_leaving_lock: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
680 |
raise tests.TestNotApplicable( |
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
681 |
"Cannot lock pre_metadir_formats remotely.") |
682 |
remote_transport = self.make_smart_server('remote') |
|
683 |
local_branch = self.make_branch('local') |
|
684 |
remote_branch = local_branch.create_clone_on_transport(remote_transport) |
|
685 |
self.assertEqual( |
|
686 |
local_branch.repository._format.supports_external_lookups, |
|
687 |
remote_branch.repository._format.supports_external_lookups) |
|
688 |
||
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
689 |
def test_clone_stacking_policy_upgrades(self): |
690 |
"""Cloning an unstackable branch format to somewhere with a default
|
|
691 |
stack-on branch upgrades branch and repo to match the target and honour
|
|
692 |
the policy.
|
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
693 |
"""
|
694 |
try: |
|
695 |
repo = self.make_repository('repo', shared=True) |
|
696 |
except errors.IncompatibleFormat: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
697 |
raise tests.TestNotApplicable('Cannot make a shared repository') |
5673.1.3
by Jelmer Vernooij
Change flexible_components to fixed_components. |
698 |
if repo.bzrdir._format.fixed_components: |
6050.1.2
by Martin
Make tests raising KnownFailure use the knownFailure method instead |
699 |
self.knownFailure( |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
700 |
"pre metadir branches do not upgrade on push "
|
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
701 |
"with stacking policy") |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
702 |
if isinstance(repo._format, |
5757.1.5
by Jelmer Vernooij
Fix import. |
703 |
knitpack_repo.RepositoryFormatKnitPack5RichRootBroken): |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
704 |
raise tests.TestNotApplicable("unsupported format") |
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
705 |
# Make a source branch in 'repo' in an unstackable branch format
|
706 |
bzrdir_format = self.repository_format._matchingbzrdir |
|
707 |
transport = self.get_transport('repo/branch') |
|
708 |
transport.mkdir('.') |
|
709 |
target_bzrdir = bzrdir_format.initialize_on_transport(transport) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
710 |
branch = _mod_branch.BzrBranchFormat6().initialize(target_bzrdir) |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
711 |
# Ensure that stack_on will be stackable and match the serializer of
|
712 |
# repo.
|
|
713 |
if isinstance(repo, remote.RemoteRepository): |
|
714 |
repo._ensure_real() |
|
715 |
info_repo = repo._real_repository |
|
4599.4.40
by Robert Collins
Fix formats for per_repository upgrade-to-stacking test. |
716 |
else: |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
717 |
info_repo = repo |
718 |
format_description = info.describe_format(info_repo.bzrdir, |
|
719 |
info_repo, None, None) |
|
720 |
formats = format_description.split(' or ') |
|
721 |
stack_on_format = formats[0] |
|
722 |
if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]: |
|
723 |
stack_on_format = "1.9" |
|
724 |
elif stack_on_format in ["dirstate-with-subtree", "rich-root", |
|
725 |
"rich-root-pack", "pack-0.92-subtree"]: |
|
726 |
stack_on_format = "1.9-rich-root" |
|
727 |
# formats not tested for above are already stackable, so we can use the
|
|
728 |
# format as-is.
|
|
729 |
stack_on = self.make_branch('stack-on-me', format=stack_on_format) |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
730 |
self.make_bzrdir('.').get_config().set_default_stack_on('stack-on-me') |
731 |
target = branch.bzrdir.clone(self.get_url('target')) |
|
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
732 |
# The target branch supports stacking.
|
733 |
self.assertTrue(target.open_branch()._format.supports_stacking()) |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
734 |
if isinstance(repo, remote.RemoteRepository): |
735 |
repo._ensure_real() |
|
736 |
repo = repo._real_repository |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
737 |
target_repo = target.open_repository() |
738 |
if isinstance(target_repo, remote.RemoteRepository): |
|
739 |
target_repo._ensure_real() |
|
740 |
target_repo = target_repo._real_repository |
|
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
741 |
# The repository format is unchanged if it could already stack, or the
|
742 |
# same as the stack on.
|
|
743 |
if repo._format.supports_external_lookups: |
|
744 |
self.assertEqual(repo._format, target_repo._format) |
|
745 |
else: |
|
746 |
self.assertEqual(stack_on.repository._format, target_repo._format) |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
747 |
|
3089.2.1
by Andrew Bennetts
Implement RemoteRepository._make_parents_provider. |
748 |
def test__make_parents_provider(self): |
749 |
"""Repositories must have a _make_parents_provider method that returns
|
|
3099.3.5
by John Arbash Meinel
Update the last couple of places that referred to Provider.get_parents() directly. |
750 |
an object with a get_parent_map method.
|
3089.2.1
by Andrew Bennetts
Implement RemoteRepository._make_parents_provider. |
751 |
"""
|
752 |
repo = self.make_repository('repo') |
|
3099.3.5
by John Arbash Meinel
Update the last couple of places that referred to Provider.get_parents() directly. |
753 |
repo._make_parents_provider().get_parent_map |
3089.2.1
by Andrew Bennetts
Implement RemoteRepository._make_parents_provider. |
754 |
|
6150.2.2
by Jelmer Vernooij
Make various make_repository methods default their shared setting to None. |
755 |
def make_repository_and_foo_bar(self, shared=None): |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
756 |
made_control = self.make_bzrdir('repository') |
757 |
repo = made_control.create_repository(shared=shared) |
|
6145.2.1
by Jelmer Vernooij
Add RepositoryFormat.supports_nesting_repositories. |
758 |
if not repo._format.supports_nesting_repositories: |
759 |
raise tests.TestNotApplicable("repository does not support " |
|
760 |
"nesting repositories") |
|
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
761 |
bzrdir.BzrDir.create_branch_convenience(self.get_url('repository/foo'), |
762 |
force_new_repo=False) |
|
763 |
bzrdir.BzrDir.create_branch_convenience(self.get_url('repository/bar'), |
|
764 |
force_new_repo=True) |
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
765 |
baz = self.make_bzrdir('repository/baz') |
766 |
qux = self.make_branch('repository/baz/qux') |
|
3140.1.6
by Aaron Bentley
Add test that nested branches are returned |
767 |
quxx = self.make_branch('repository/baz/qux/quxx') |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
768 |
return repo |
769 |
||
770 |
def test_find_branches(self): |
|
6150.2.2
by Jelmer Vernooij
Make various make_repository methods default their shared setting to None. |
771 |
repo = self.make_repository_and_foo_bar() |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
772 |
branches = repo.find_branches() |
773 |
self.assertContainsRe(branches[-1].base, 'repository/foo/$') |
|
3140.1.6
by Aaron Bentley
Add test that nested branches are returned |
774 |
self.assertContainsRe(branches[-3].base, 'repository/baz/qux/$') |
775 |
self.assertContainsRe(branches[-2].base, 'repository/baz/qux/quxx/$') |
|
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
776 |
# in some formats, creating a repo creates a branch
|
3140.1.6
by Aaron Bentley
Add test that nested branches are returned |
777 |
if len(branches) == 6: |
778 |
self.assertContainsRe(branches[-4].base, 'repository/baz/$') |
|
779 |
self.assertContainsRe(branches[-5].base, 'repository/bar/$') |
|
780 |
self.assertContainsRe(branches[-6].base, 'repository/$') |
|
781 |
else: |
|
782 |
self.assertEqual(4, len(branches)) |
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
783 |
self.assertContainsRe(branches[-4].base, 'repository/bar/$') |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
784 |
|
785 |
def test_find_branches_using(self): |
|
786 |
try: |
|
787 |
repo = self.make_repository_and_foo_bar(shared=True) |
|
788 |
except errors.IncompatibleFormat: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
789 |
raise tests.TestNotApplicable |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
790 |
branches = repo.find_branches(using=True) |
791 |
self.assertContainsRe(branches[-1].base, 'repository/foo/$') |
|
792 |
# in some formats, creating a repo creates a branch
|
|
793 |
if len(branches) == 2: |
|
794 |
self.assertContainsRe(branches[-2].base, 'repository/$') |
|
795 |
else: |
|
796 |
self.assertEqual(1, len(branches)) |
|
797 |
||
3140.1.9
by Aaron Bentley
Optimize find_branches for standalone repositories |
798 |
def test_find_branches_using_standalone(self): |
799 |
branch = self.make_branch('branch') |
|
6145.2.1
by Jelmer Vernooij
Add RepositoryFormat.supports_nesting_repositories. |
800 |
if not branch.repository._format.supports_nesting_repositories: |
801 |
raise tests.TestNotApplicable("format does not support nesting " |
|
802 |
"repositories") |
|
3140.1.9
by Aaron Bentley
Optimize find_branches for standalone repositories |
803 |
contained = self.make_branch('branch/contained') |
804 |
branches = branch.repository.find_branches(using=True) |
|
805 |
self.assertEqual([branch.base], [b.base for b in branches]) |
|
806 |
branches = branch.repository.find_branches(using=False) |
|
807 |
self.assertEqual([branch.base, contained.base], |
|
808 |
[b.base for b in branches]) |
|
809 |
||
810 |
def test_find_branches_using_empty_standalone_repo(self): |
|
6123.9.10
by Jelmer Vernooij
Improve tag handling. |
811 |
repo = self.make_repository('repo', shared=False) |
3140.1.9
by Aaron Bentley
Optimize find_branches for standalone repositories |
812 |
try: |
813 |
repo.bzrdir.open_branch() |
|
814 |
except errors.NotBranchError: |
|
815 |
self.assertEqual([], repo.find_branches(using=True)) |
|
816 |
else: |
|
817 |
self.assertEqual([repo.bzrdir.root_transport.base], |
|
818 |
[b.base for b in repo.find_branches(using=True)]) |
|
819 |
||
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
820 |
def test_set_get_make_working_trees_true(self): |
821 |
repo = self.make_repository('repo') |
|
3349.1.2
by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired |
822 |
try: |
823 |
repo.set_make_working_trees(True) |
|
6104.2.2
by Jelmer Vernooij
Expect UnsupportedOperation when set_make_working_trees is not available. |
824 |
except (errors.RepositoryUpgradeRequired, errors.UnsupportedOperation), e: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
825 |
raise tests.TestNotApplicable('Format does not support this flag.') |
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
826 |
self.assertTrue(repo.make_working_trees()) |
827 |
||
828 |
def test_set_get_make_working_trees_false(self): |
|
829 |
repo = self.make_repository('repo') |
|
830 |
try: |
|
831 |
repo.set_make_working_trees(False) |
|
6104.2.2
by Jelmer Vernooij
Expect UnsupportedOperation when set_make_working_trees is not available. |
832 |
except (errors.RepositoryUpgradeRequired, errors.UnsupportedOperation), e: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
833 |
raise tests.TestNotApplicable('Format does not support this flag.') |
3349.1.2
by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired |
834 |
self.assertFalse(repo.make_working_trees()) |
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
835 |
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
836 |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
837 |
class TestRepositoryLocking(per_repository.TestCaseWithRepository): |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
838 |
|
839 |
def test_leave_lock_in_place(self): |
|
840 |
repo = self.make_repository('r') |
|
841 |
# Lock the repository, then use leave_lock_in_place so that when we
|
|
842 |
# unlock the repository the lock is still held on disk.
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
843 |
token = repo.lock_write().repository_token |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
844 |
try: |
2018.5.76
by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None. |
845 |
if token is None: |
846 |
# This test does not apply, because this repository refuses lock
|
|
847 |
# tokens.
|
|
848 |
self.assertRaises(NotImplementedError, repo.leave_lock_in_place) |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
849 |
return
|
2018.5.76
by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None. |
850 |
repo.leave_lock_in_place() |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
851 |
finally: |
852 |
repo.unlock() |
|
853 |
# We should be unable to relock the repo.
|
|
854 |
self.assertRaises(errors.LockContention, repo.lock_write) |
|
4327.1.8
by Vincent Ladeuil
Fix 4 more lock-related test failures. |
855 |
# Cleanup
|
856 |
repo.lock_write(token) |
|
857 |
repo.dont_leave_lock_in_place() |
|
858 |
repo.unlock() |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
859 |
|
860 |
def test_dont_leave_lock_in_place(self): |
|
861 |
repo = self.make_repository('r') |
|
862 |
# Create a lock on disk.
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
863 |
token = repo.lock_write().repository_token |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
864 |
try: |
865 |
if token is None: |
|
866 |
# This test does not apply, because this repository refuses lock
|
|
867 |
# tokens.
|
|
2018.5.76
by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None. |
868 |
self.assertRaises(NotImplementedError, |
869 |
repo.dont_leave_lock_in_place) |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
870 |
return
|
871 |
try: |
|
872 |
repo.leave_lock_in_place() |
|
873 |
except NotImplementedError: |
|
874 |
# This repository doesn't support this API.
|
|
875 |
return
|
|
876 |
finally: |
|
877 |
repo.unlock() |
|
878 |
# Reacquire the lock (with a different repository object) by using the
|
|
879 |
# token.
|
|
880 |
new_repo = repo.bzrdir.open_repository() |
|
881 |
new_repo.lock_write(token=token) |
|
882 |
# Call dont_leave_lock_in_place, so that the lock will be released by
|
|
883 |
# this instance, even though the lock wasn't originally acquired by it.
|
|
884 |
new_repo.dont_leave_lock_in_place() |
|
885 |
new_repo.unlock() |
|
886 |
# Now the repository is unlocked. Test this by locking it (without a
|
|
887 |
# token).
|
|
888 |
repo.lock_write() |
|
889 |
repo.unlock() |
|
890 |
||
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
891 |
def test_lock_read_then_unlock(self): |
892 |
# Calling lock_read then unlocking should work without errors.
|
|
893 |
repo = self.make_repository('r') |
|
894 |
repo.lock_read() |
|
895 |
repo.unlock() |
|
896 |
||
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
897 |
def test_lock_read_returns_unlockable(self): |
898 |
repo = self.make_repository('r') |
|
899 |
self.assertThat(repo.lock_read, ReturnsUnlockable(repo)) |
|
900 |
||
901 |
def test_lock_write_returns_unlockable(self): |
|
902 |
repo = self.make_repository('r') |
|
903 |
self.assertThat(repo.lock_write, ReturnsUnlockable(repo)) |
|
904 |
||
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
905 |
|
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
906 |
# FIXME: document why this is a TestCaseWithTransport rather than a
|
907 |
# TestCaseWithRepository
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
908 |
class TestEscaping(tests.TestCaseWithTransport): |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
909 |
"""Test that repositories can be stored correctly on VFAT transports.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
910 |
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
911 |
Makes sure we have proper escaping of invalid characters, etc.
|
912 |
||
913 |
It'd be better to test all operations on the FakeVFATTransportDecorator,
|
|
914 |
but working trees go straight to the os not through the Transport layer.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
915 |
Therefore we build some history first in the regular way and then
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
916 |
check it's safe to access for vfat.
|
917 |
"""
|
|
918 |
||
919 |
def test_on_vfat(self): |
|
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
920 |
# dont bother with remote repository testing, because this test is
|
921 |
# about local disk layout/support.
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
922 |
if isinstance(self.repository_format, remote.RemoteRepositoryFormat): |
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
923 |
return
|
5017.3.42
by Vincent Ladeuil
-s bt.per_repository.test_repo passing |
924 |
self.transport_server = test_server.FakeVFATServer |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
925 |
FOO_ID = 'foo<:>ID' |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
926 |
REV_ID = 'revid-1' |
927 |
# this makes a default format repository always, which is wrong:
|
|
928 |
# it should be a TestCaseWithRepository in order to get the
|
|
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
929 |
# default format.
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
930 |
wt = self.make_branch_and_tree('repo') |
2052.2.1
by Alexander Belchenko
test_on_vfat win32 fix: use binary line-endings |
931 |
self.build_tree(["repo/foo"], line_endings='binary') |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
932 |
# add file with id containing wierd characters
|
933 |
wt.add(['foo'], [FOO_ID]) |
|
934 |
wt.commit('this is my new commit', rev_id=REV_ID) |
|
935 |
# now access over vfat; should be safe
|
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
936 |
branch = bzrdir.BzrDir.open(self.get_url('repo')).open_branch() |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
937 |
revtree = branch.repository.revision_tree(REV_ID) |
3015.2.13
by Robert Collins
More lock correctness for the use of get_file_text in repository_implementations. |
938 |
revtree.lock_read() |
939 |
self.addCleanup(revtree.unlock) |
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
940 |
contents = revtree.get_file_text(FOO_ID) |
941 |
self.assertEqual(contents, 'contents of repo/foo\n') |
|
2520.4.54
by Aaron Bentley
Hang a create_bundle method off repository |
942 |
|
943 |
def test_create_bundle(self): |
|
944 |
wt = self.make_branch_and_tree('repo') |
|
945 |
self.build_tree(['repo/file1']) |
|
946 |
wt.add('file1') |
|
947 |
wt.commit('file1', rev_id='rev1') |
|
948 |
fileobj = StringIO() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
949 |
wt.branch.repository.create_bundle( |
950 |
'rev1', _mod_revision.NULL_REVISION, fileobj) |
|
5158.6.4
by Martin Pool
Repository implements ControlComponent too |
951 |
|
952 |
||
953 |
class TestRepositoryControlComponent(per_repository.TestCaseWithRepository): |
|
954 |
"""Repository implementations adequately implement ControlComponent."""
|
|
5673.1.1
by Jelmer Vernooij
Add flexible_components boolean to ControlDir if the |
955 |
|
5158.6.4
by Martin Pool
Repository implements ControlComponent too |
956 |
def test_urls(self): |
957 |
repo = self.make_repository('repo') |
|
958 |
self.assertIsInstance(repo.user_url, str) |
|
959 |
self.assertEqual(repo.user_url, repo.user_transport.base) |
|
960 |
# for all current bzrdir implementations the user dir must be
|
|
961 |
# above the control dir but we might need to relax that?
|
|
962 |
self.assertEqual(repo.control_url.find(repo.user_url), 0) |
|
963 |
self.assertEqual(repo.control_url, repo.control_transport.base) |