bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2010, 2011, 2012, 2016 Canonical Ltd
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
"""Tests for bzrdir implementations - tests a bzrdir format."""
|
|
18 |
||
19 |
import errno |
|
20 |
from stat import S_ISDIR |
|
21 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
22 |
import breezy.branch |
23 |
from breezy import ( |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
24 |
controldir, |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
25 |
errors, |
5699.4.7
by Jelmer Vernooij
Fix imports. |
26 |
repository, |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
27 |
revision as _mod_revision, |
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
28 |
transport, |
5699.4.7
by Jelmer Vernooij
Fix imports. |
29 |
workingtree, |
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
30 |
)
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
31 |
from breezy.bzr import ( |
32 |
bzrdir, |
|
33 |
)
|
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
34 |
from breezy.bzr.remote import RemoteBzrDirFormat |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
35 |
from breezy.tests import ( |
6164.2.1
by Jelmer Vernooij
Skip tests if the repository doesn't support ghosts. |
36 |
TestNotApplicable, |
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
37 |
TestSkipped, |
38 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
39 |
from breezy.tests.per_bzrdir import TestCaseWithBzrDir |
40 |
from breezy.transport.local import ( |
|
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
41 |
LocalTransport, |
42 |
)
|
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
43 |
|
44 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
45 |
class AnonymousTestBranchFormat(breezy.branch.BranchFormat): |
5699.4.7
by Jelmer Vernooij
Fix imports. |
46 |
"""An anonymous branch format (does not have a format string)""" |
47 |
||
48 |
def get_format_string(self): |
|
49 |
raise NotImplementedError(self.get_format_string) |
|
50 |
||
51 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
52 |
class IdentifiableTestBranchFormat(breezy.branch.BranchFormat): |
5699.4.7
by Jelmer Vernooij
Fix imports. |
53 |
"""An identifable branch format (has a format string)""" |
54 |
||
55 |
def get_format_string(self): |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
56 |
return b"I have an identity" |
5699.4.7
by Jelmer Vernooij
Fix imports. |
57 |
|
58 |
||
59 |
class AnonymousTestRepositoryFormat(repository.RepositoryFormat): |
|
60 |
"""An anonymous branch format (does not have a format string)""" |
|
61 |
||
62 |
def get_format_string(self): |
|
63 |
raise NotImplementedError(self.get_format_string) |
|
64 |
||
65 |
||
66 |
class IdentifiableTestRepositoryFormat(repository.RepositoryFormat): |
|
67 |
"""An identifable branch format (has a format string)""" |
|
68 |
||
69 |
def get_format_string(self): |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
70 |
return b"I have an identity" |
5699.4.7
by Jelmer Vernooij
Fix imports. |
71 |
|
72 |
||
73 |
class AnonymousTestWorkingTreeFormat(workingtree.WorkingTreeFormat): |
|
74 |
"""An anonymous branch format (does not have a format string)""" |
|
75 |
||
76 |
def get_format_string(self): |
|
77 |
raise NotImplementedError(self.get_format_string) |
|
78 |
||
79 |
||
80 |
class IdentifiableTestWorkingTreeFormat(workingtree.WorkingTreeFormat): |
|
81 |
"""An identifable branch format (has a format string)""" |
|
82 |
||
83 |
def get_format_string(self): |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
84 |
return b"I have an identity" |
5699.4.7
by Jelmer Vernooij
Fix imports. |
85 |
|
86 |
||
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
87 |
class TestBzrDir(TestCaseWithBzrDir): |
88 |
||
89 |
# Many of these tests test for disk equality rather than checking
|
|
90 |
# for semantic equivalence. This works well for some tests but
|
|
91 |
# is not good at handling changes in representation or the addition
|
|
92 |
# or removal of control data. It would be nice to for instance:
|
|
93 |
# sprout a new branch, check that the nickname has been reset by hand
|
|
94 |
# and then set the nickname to match the source branch, at which point
|
|
95 |
# a semantic equivalence should pass
|
|
96 |
||
97 |
def assertDirectoriesEqual(self, source, target, ignore_list=[]): |
|
98 |
"""Assert that the content of source and target are identical. |
|
99 |
||
100 |
paths in ignore list will be completely ignored.
|
|
101 |
||
102 |
We ignore paths that represent data which is allowed to change during
|
|
103 |
a clone or sprout: for instance, inventory.knit contains gzip fragements
|
|
104 |
which have timestamps in them, and as we have read the inventory from
|
|
105 |
the source knit, the already-read data is recompressed rather than
|
|
106 |
reading it again, which leads to changed timestamps. This is ok though,
|
|
107 |
because the inventory.kndx file is not ignored, and the integrity of
|
|
108 |
knit joins is tested by test_knit and test_versionedfile.
|
|
109 |
||
110 |
:seealso: Additionally, assertRepositoryHasSameItems provides value
|
|
111 |
rather than representation checking of repositories for
|
|
112 |
equivalence.
|
|
113 |
"""
|
|
114 |
files = [] |
|
115 |
directories = ['.'] |
|
116 |
while directories: |
|
117 |
dir = directories.pop() |
|
118 |
for path in set(source.list_dir(dir) + target.list_dir(dir)): |
|
119 |
path = dir + '/' + path |
|
120 |
if path in ignore_list: |
|
121 |
continue
|
|
122 |
try: |
|
123 |
stat = source.stat(path) |
|
124 |
except errors.NoSuchFile: |
|
125 |
self.fail('%s not in source' % path) |
|
126 |
if S_ISDIR(stat.st_mode): |
|
127 |
self.assertTrue(S_ISDIR(target.stat(path).st_mode)) |
|
128 |
directories.append(path) |
|
129 |
else: |
|
6437.20.5
by Wouter van Heyst
express intent more pithily with transport.get_bytes |
130 |
self.assertEqualDiff(source.get_bytes(path), |
131 |
target.get_bytes(path), |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
132 |
"text for file %r differs:\n" % path) |
133 |
||
134 |
def assertRepositoryHasSameItems(self, left_repo, right_repo): |
|
135 |
"""require left_repo and right_repo to contain the same data.""" |
|
136 |
# XXX: TODO: Doesn't work yet, because we need to be able to compare
|
|
137 |
# local repositories to remote ones... but this is an as-yet unsolved
|
|
138 |
# aspect of format management and the Remote protocols...
|
|
139 |
# self.assertEqual(left_repo._format.__class__,
|
|
140 |
# right_repo._format.__class__)
|
|
6754.8.4
by Jelmer Vernooij
Use new context stuff. |
141 |
with left_repo.lock_read(), right_repo.lock_read(): |
142 |
# revs
|
|
143 |
all_revs = left_repo.all_revision_ids() |
|
144 |
self.assertEqual(left_repo.all_revision_ids(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
145 |
right_repo.all_revision_ids()) |
6754.8.4
by Jelmer Vernooij
Use new context stuff. |
146 |
for rev_id in left_repo.all_revision_ids(): |
147 |
self.assertEqual(left_repo.get_revision(rev_id), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
148 |
right_repo.get_revision(rev_id)) |
6754.8.4
by Jelmer Vernooij
Use new context stuff. |
149 |
# Assert the revision trees (and thus the inventories) are equal
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
150 |
|
151 |
def sort_key(rev_tree): return rev_tree.get_revision_id() |
|
6754.8.4
by Jelmer Vernooij
Use new context stuff. |
152 |
rev_trees_a = sorted( |
153 |
left_repo.revision_trees(all_revs), key=sort_key) |
|
154 |
rev_trees_b = sorted( |
|
155 |
right_repo.revision_trees(all_revs), key=sort_key) |
|
156 |
for tree_a, tree_b in zip(rev_trees_a, rev_trees_b): |
|
157 |
self.assertEqual([], list(tree_a.iter_changes(tree_b))) |
|
158 |
# texts
|
|
159 |
text_index = left_repo._generate_text_key_index() |
|
160 |
self.assertEqual(text_index, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
161 |
right_repo._generate_text_key_index()) |
6754.8.4
by Jelmer Vernooij
Use new context stuff. |
162 |
desired_files = [] |
163 |
for file_id, revision_id in text_index: |
|
164 |
desired_files.append( |
|
165 |
(file_id, revision_id, (file_id, revision_id))) |
|
7045.1.1
by Jelmer Vernooij
Fix another 300 tests. |
166 |
left_texts = [(identifier, b"".join(bytes_iterator)) for |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
167 |
(identifier, bytes_iterator) in |
168 |
left_repo.iter_files_bytes(desired_files)] |
|
7045.1.1
by Jelmer Vernooij
Fix another 300 tests. |
169 |
right_texts = [(identifier, b"".join(bytes_iterator)) for |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
170 |
(identifier, bytes_iterator) in |
171 |
right_repo.iter_files_bytes(desired_files)] |
|
6754.8.4
by Jelmer Vernooij
Use new context stuff. |
172 |
left_texts.sort() |
173 |
right_texts.sort() |
|
174 |
self.assertEqual(left_texts, right_texts) |
|
175 |
# signatures
|
|
176 |
for rev_id in all_revs: |
|
177 |
try: |
|
178 |
left_text = left_repo.get_signature_text(rev_id) |
|
179 |
except errors.NoSuchRevision: |
|
180 |
continue
|
|
181 |
right_text = right_repo.get_signature_text(rev_id) |
|
182 |
self.assertEqual(left_text, right_text) |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
183 |
|
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
184 |
def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None, |
185 |
force_new_repo=False, accelerator_tree=None, |
|
186 |
create_tree_if_local=True): |
|
187 |
"""Sprout from_bzrdir into to_url, or raise TestSkipped. |
|
188 |
||
189 |
A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
|
|
190 |
TestSkipped. Returns the newly sprouted bzrdir.
|
|
191 |
"""
|
|
192 |
to_transport = transport.get_transport(to_url) |
|
193 |
if not isinstance(to_transport, LocalTransport): |
|
194 |
raise TestSkipped('Cannot sprout to remote bzrdirs.') |
|
195 |
target = from_bzrdir.sprout(to_url, revision_id=revision_id, |
|
196 |
force_new_repo=force_new_repo, |
|
197 |
possible_transports=[to_transport], |
|
198 |
accelerator_tree=accelerator_tree, |
|
199 |
create_tree_if_local=create_tree_if_local) |
|
200 |
return target |
|
201 |
||
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
202 |
def skipIfNoWorkingTree(self, a_controldir): |
203 |
"""Raises TestSkipped if a_controldir doesn't have a working tree. |
|
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
204 |
|
205 |
If the bzrdir does have a workingtree, this is a no-op.
|
|
206 |
"""
|
|
207 |
try: |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
208 |
a_controldir.open_workingtree() |
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
209 |
except (errors.NotLocalUrl, errors.NoWorkingTree): |
210 |
raise TestSkipped("bzrdir on transport %r has no working tree" |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
211 |
% a_controldir.transport) |
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
212 |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
213 |
def createWorkingTreeOrSkip(self, a_controldir): |
214 |
"""Create a working tree on a_controldir, or raise TestSkipped. |
|
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
215 |
|
216 |
A simple wrapper for create_workingtree that translates NotLocalUrl into
|
|
217 |
TestSkipped. Returns the newly created working tree.
|
|
218 |
"""
|
|
219 |
try: |
|
5042.1.3
by Martin Pool
Update a test for BzrDir.create_workingtree so that it covers bug 524627 |
220 |
# This passes in many named options to make sure they're
|
221 |
# understood by subclasses: see
|
|
222 |
# <https://bugs.launchpad.net/bzr/+bug/524627>.
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
223 |
return a_controldir.create_workingtree( |
5042.1.3
by Martin Pool
Update a test for BzrDir.create_workingtree so that it covers bug 524627 |
224 |
revision_id=None, |
225 |
from_branch=None, |
|
226 |
accelerator_tree=None, |
|
227 |
hardlink=False) |
|
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
228 |
except errors.NotLocalUrl: |
229 |
raise TestSkipped("cannot make working tree with transport %r" |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
230 |
% a_controldir.transport) |
5363.2.30
by Jelmer Vernooij
actually run per_bzrdir tests. |
231 |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
232 |
def test_clone_bzrdir_repository_under_shared_force_new_repo(self): |
233 |
tree = self.make_branch_and_tree('commit_tree') |
|
234 |
self.build_tree(['commit_tree/foo']) |
|
235 |
tree.add('foo') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
236 |
tree.commit('revision 1', rev_id=b'1') |
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
237 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
238 |
repo = dir.create_repository() |
239 |
repo.fetch(tree.branch.repository) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
240 |
self.assertTrue(repo.has_revision(b'1')) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
241 |
try: |
242 |
self.make_repository('target', shared=True) |
|
243 |
except errors.IncompatibleFormat: |
|
244 |
return
|
|
245 |
target = dir.clone(self.get_url('target/child'), force_new_repo=True) |
|
246 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
247 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
248 |
['./.bzr/repository', |
|
249 |
])
|
|
250 |
self.assertRepositoryHasSameItems(tree.branch.repository, repo) |
|
251 |
||
252 |
def test_clone_bzrdir_branch_and_repo(self): |
|
253 |
tree = self.make_branch_and_tree('commit_tree') |
|
254 |
self.build_tree(['commit_tree/foo']) |
|
255 |
tree.add('foo') |
|
256 |
tree.commit('revision 1') |
|
257 |
source = self.make_branch('source') |
|
258 |
tree.branch.repository.copy_content_into(source.repository) |
|
259 |
tree.branch.copy_content_into(source) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
260 |
dir = source.controldir |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
261 |
target = dir.clone(self.get_url('target')) |
262 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
263 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
264 |
[
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
265 |
'./.bzr/basis-inventory-cache', |
266 |
'./.bzr/checkout/stat-cache', |
|
267 |
'./.bzr/merge-hashes', |
|
268 |
'./.bzr/repository', |
|
269 |
'./.bzr/stat-cache', |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
270 |
])
|
271 |
self.assertRepositoryHasSameItems( |
|
272 |
tree.branch.repository, target.open_repository()) |
|
273 |
||
274 |
def test_clone_on_transport(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
275 |
a_dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
276 |
target_transport = a_dir.root_transport.clone('..').clone('target') |
277 |
target = a_dir.clone_on_transport(target_transport) |
|
278 |
self.assertNotEqual(a_dir.transport.base, target.transport.base) |
|
279 |
self.assertDirectoriesEqual(a_dir.root_transport, target.root_transport, |
|
280 |
['./.bzr/merge-hashes']) |
|
281 |
||
282 |
def test_clone_bzrdir_empty(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
283 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
284 |
target = dir.clone(self.get_url('target')) |
285 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
286 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
287 |
['./.bzr/merge-hashes']) |
|
288 |
||
289 |
def test_clone_bzrdir_empty_force_new_ignored(self): |
|
290 |
# the force_new_repo parameter should have no effect on an empty
|
|
291 |
# bzrdir's clone logic
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
292 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
293 |
target = dir.clone(self.get_url('target'), force_new_repo=True) |
294 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
295 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
296 |
['./.bzr/merge-hashes']) |
|
297 |
||
298 |
def test_clone_bzrdir_repository(self): |
|
299 |
tree = self.make_branch_and_tree('commit_tree') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
300 |
self.build_tree( |
301 |
['foo'], transport=tree.controldir.transport.clone('..')) |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
302 |
tree.add('foo') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
303 |
tree.commit('revision 1', rev_id=b'1') |
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
304 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
305 |
repo = dir.create_repository() |
306 |
repo.fetch(tree.branch.repository) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
307 |
self.assertTrue(repo.has_revision(b'1')) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
308 |
target = dir.clone(self.get_url('target')) |
309 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
310 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
311 |
[
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
312 |
'./.bzr/merge-hashes', |
313 |
'./.bzr/repository', |
|
314 |
])
|
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
315 |
self.assertRepositoryHasSameItems(tree.branch.repository, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
316 |
target.open_repository()) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
317 |
|
318 |
def test_clone_bzrdir_tree_branch_repo(self): |
|
319 |
tree = self.make_branch_and_tree('source') |
|
320 |
self.build_tree(['source/foo']) |
|
321 |
tree.add('foo') |
|
322 |
tree.commit('revision 1') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
323 |
dir = tree.controldir |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
324 |
target = dir.clone(self.get_url('target')) |
325 |
self.skipIfNoWorkingTree(target) |
|
326 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
327 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
328 |
['./.bzr/stat-cache', |
|
329 |
'./.bzr/checkout/dirstate', |
|
330 |
'./.bzr/checkout/stat-cache', |
|
331 |
'./.bzr/checkout/merge-hashes', |
|
332 |
'./.bzr/merge-hashes', |
|
333 |
'./.bzr/repository', |
|
334 |
])
|
|
335 |
self.assertRepositoryHasSameItems(tree.branch.repository, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
336 |
target.open_branch().repository) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
337 |
target.open_workingtree().revert() |
338 |
||
339 |
def test_revert_inventory(self): |
|
340 |
tree = self.make_branch_and_tree('source') |
|
341 |
self.build_tree(['source/foo']) |
|
342 |
tree.add('foo') |
|
343 |
tree.commit('revision 1') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
344 |
dir = tree.controldir |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
345 |
target = dir.clone(self.get_url('target')) |
346 |
self.skipIfNoWorkingTree(target) |
|
347 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
348 |
['./.bzr/stat-cache', |
|
349 |
'./.bzr/checkout/dirstate', |
|
350 |
'./.bzr/checkout/stat-cache', |
|
351 |
'./.bzr/checkout/merge-hashes', |
|
352 |
'./.bzr/merge-hashes', |
|
353 |
'./.bzr/repository', |
|
354 |
])
|
|
355 |
self.assertRepositoryHasSameItems(tree.branch.repository, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
356 |
target.open_branch().repository) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
357 |
|
358 |
target.open_workingtree().revert() |
|
359 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
360 |
['./.bzr/stat-cache', |
|
361 |
'./.bzr/checkout/dirstate', |
|
362 |
'./.bzr/checkout/stat-cache', |
|
363 |
'./.bzr/checkout/merge-hashes', |
|
364 |
'./.bzr/merge-hashes', |
|
365 |
'./.bzr/repository', |
|
366 |
])
|
|
367 |
self.assertRepositoryHasSameItems(tree.branch.repository, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
368 |
target.open_branch().repository) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
369 |
|
370 |
def test_clone_bzrdir_tree_branch_reference(self): |
|
371 |
# a tree with a branch reference (aka a checkout)
|
|
372 |
# should stay a checkout on clone.
|
|
373 |
referenced_branch = self.make_branch('referencced') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
374 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
375 |
try: |
6437.7.3
by Jelmer Vernooij
Use ControlDir.set_branch_reference. |
376 |
dir.set_branch_reference(referenced_branch) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
377 |
except errors.IncompatibleFormat: |
378 |
# this is ok too, not all formats have to support references.
|
|
379 |
return
|
|
380 |
self.createWorkingTreeOrSkip(dir) |
|
381 |
target = dir.clone(self.get_url('target')) |
|
382 |
self.skipIfNoWorkingTree(target) |
|
383 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
384 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
385 |
['./.bzr/stat-cache', |
|
386 |
'./.bzr/checkout/stat-cache', |
|
387 |
'./.bzr/checkout/merge-hashes', |
|
388 |
'./.bzr/merge-hashes', |
|
389 |
'./.bzr/repository/inventory.knit', |
|
390 |
])
|
|
391 |
||
392 |
def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self): |
|
393 |
# by default cloning into a shared repo uses the shared repo.
|
|
394 |
tree = self.make_branch_and_tree('commit_tree') |
|
395 |
self.build_tree(['commit_tree/foo']) |
|
396 |
tree.add('foo') |
|
397 |
tree.commit('revision 1') |
|
398 |
source = self.make_branch('source') |
|
399 |
tree.branch.repository.copy_content_into(source.repository) |
|
400 |
tree.branch.copy_content_into(source) |
|
401 |
try: |
|
402 |
self.make_repository('target', shared=True) |
|
403 |
except errors.IncompatibleFormat: |
|
404 |
return
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
405 |
dir = source.controldir |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
406 |
target = dir.clone(self.get_url('target/child'), force_new_repo=True) |
407 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
408 |
repo = target.open_repository() |
|
409 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
410 |
['./.bzr/repository', |
|
411 |
])
|
|
412 |
self.assertRepositoryHasSameItems(tree.branch.repository, repo) |
|
413 |
||
414 |
def test_clone_bzrdir_branch_reference(self): |
|
415 |
# cloning should preserve the reference status of the branch in a bzrdir
|
|
416 |
referenced_branch = self.make_branch('referencced') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
417 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
418 |
try: |
6437.7.3
by Jelmer Vernooij
Use ControlDir.set_branch_reference. |
419 |
dir.set_branch_reference(referenced_branch) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
420 |
except errors.IncompatibleFormat: |
421 |
# this is ok too, not all formats have to support references.
|
|
422 |
return
|
|
423 |
target = dir.clone(self.get_url('target')) |
|
424 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
425 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
426 |
||
427 |
def test_sprout_bzrdir_repository(self): |
|
428 |
tree = self.make_branch_and_tree('commit_tree') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
429 |
self.build_tree( |
430 |
['foo'], transport=tree.controldir.transport.clone('..')) |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
431 |
tree.add('foo') |
6855.4.1
by Jelmer Vernooij
Yet more bees. |
432 |
tree.commit('revision 1', rev_id=b'1') |
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
433 |
dir = self.make_controldir('source') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
434 |
repo = dir.create_repository() |
435 |
repo.fetch(tree.branch.repository) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
436 |
self.assertTrue(repo.has_revision(b'1')) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
437 |
try: |
438 |
self.assertTrue( |
|
439 |
_mod_revision.is_null(_mod_revision.ensure_null( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
440 |
dir.open_branch().last_revision()))) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
441 |
except errors.NotBranchError: |
442 |
pass
|
|
443 |
target = dir.sprout(self.get_url('target')) |
|
444 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
445 |
# testing inventory isn't reasonable for repositories
|
|
446 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
447 |
[
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
448 |
'./.bzr/branch', |
449 |
'./.bzr/checkout', |
|
450 |
'./.bzr/inventory', |
|
451 |
'./.bzr/parent', |
|
452 |
'./.bzr/repository/inventory.knit', |
|
453 |
])
|
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
454 |
try: |
455 |
local_inventory = dir.transport.local_abspath('inventory') |
|
456 |
except errors.NotLocalUrl: |
|
457 |
return
|
|
458 |
try: |
|
459 |
# If we happen to have a tree, we'll guarantee everything
|
|
460 |
# except for the tree root is the same.
|
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
461 |
with open(local_inventory, 'rb') as inventory_f: |
462 |
self.assertContainsRe(inventory_f.read(), |
|
463 |
b'<inventory format="5">\n</inventory>\n') |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
464 |
except IOError as e: |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
465 |
if e.errno != errno.ENOENT: |
466 |
raise
|
|
467 |
||
468 |
def test_sprout_bzrdir_branch_and_repo(self): |
|
469 |
tree = self.make_branch_and_tree('commit_tree') |
|
470 |
self.build_tree(['commit_tree/foo']) |
|
471 |
tree.add('foo') |
|
472 |
tree.commit('revision 1') |
|
473 |
source = self.make_branch('source') |
|
474 |
tree.branch.repository.copy_content_into(source.repository) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
475 |
tree.controldir.open_branch().copy_content_into(source) |
476 |
dir = source.controldir |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
477 |
target = dir.sprout(self.get_url('target')) |
478 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
479 |
target_repo = target.open_repository() |
|
480 |
self.assertRepositoryHasSameItems(source.repository, target_repo) |
|
481 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
482 |
[
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
483 |
'./.bzr/basis-inventory-cache', |
484 |
'./.bzr/branch/branch.conf', |
|
485 |
'./.bzr/branch/parent', |
|
486 |
'./.bzr/checkout', |
|
487 |
'./.bzr/checkout/inventory', |
|
488 |
'./.bzr/checkout/stat-cache', |
|
489 |
'./.bzr/inventory', |
|
490 |
'./.bzr/parent', |
|
491 |
'./.bzr/repository', |
|
492 |
'./.bzr/stat-cache', |
|
493 |
'./foo', |
|
494 |
])
|
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
495 |
|
496 |
def test_sprout_bzrdir_tree_branch_repo(self): |
|
497 |
tree = self.make_branch_and_tree('source') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
498 |
self.build_tree( |
499 |
['foo'], transport=tree.controldir.transport.clone('..')) |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
500 |
tree.add('foo') |
501 |
tree.commit('revision 1') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
502 |
dir = tree.controldir |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
503 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
504 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
505 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
506 |
[
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
507 |
'./.bzr/branch', |
508 |
'./.bzr/checkout/dirstate', |
|
509 |
'./.bzr/checkout/stat-cache', |
|
510 |
'./.bzr/checkout/inventory', |
|
511 |
'./.bzr/inventory', |
|
512 |
'./.bzr/parent', |
|
513 |
'./.bzr/repository', |
|
514 |
'./.bzr/stat-cache', |
|
515 |
])
|
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
516 |
self.assertRepositoryHasSameItems( |
517 |
tree.branch.repository, target.open_repository()) |
|
518 |
||
519 |
def test_retire_bzrdir(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
520 |
bd = self.make_controldir('.') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
521 |
transport = bd.root_transport |
522 |
# must not overwrite existing directories
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
523 |
self.build_tree(['.bzr.retired.0/', '.bzr.retired.0/junk', ], |
524 |
transport=transport) |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
525 |
self.assertTrue(transport.has('.bzr')) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
526 |
bd.retire_bzrdir() |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
527 |
self.assertFalse(transport.has('.bzr')) |
528 |
self.assertTrue(transport.has('.bzr.retired.1')) |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
529 |
|
530 |
def test_retire_bzrdir_limited(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
531 |
bd = self.make_controldir('.') |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
532 |
transport = bd.root_transport |
533 |
# must not overwrite existing directories
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
534 |
self.build_tree(['.bzr.retired.0/', '.bzr.retired.0/junk', ], |
535 |
transport=transport) |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
536 |
self.assertTrue(transport.has('.bzr')) |
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
537 |
self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
538 |
bd.retire_bzrdir, limit=0) |
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
539 |
|
540 |
def test_get_branch_transport(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
541 |
dir = self.make_controldir('.') |
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
542 |
# without a format, get_branch_transport gives use a transport
|
543 |
# which -may- point to an existing dir.
|
|
544 |
self.assertTrue(isinstance(dir.get_branch_transport(None), |
|
545 |
transport.Transport)) |
|
546 |
# with a given format, either the bzr dir supports identifiable
|
|
547 |
# branches, or it supports anonymous branch formats, but not both.
|
|
548 |
anonymous_format = AnonymousTestBranchFormat() |
|
549 |
identifiable_format = IdentifiableTestBranchFormat() |
|
550 |
try: |
|
551 |
found_transport = dir.get_branch_transport(anonymous_format) |
|
552 |
self.assertRaises(errors.IncompatibleFormat, |
|
553 |
dir.get_branch_transport, |
|
554 |
identifiable_format) |
|
555 |
except errors.IncompatibleFormat: |
|
556 |
found_transport = dir.get_branch_transport(identifiable_format) |
|
557 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
558 |
# and the dir which has been initialized for us must exist.
|
|
559 |
found_transport.list_dir('.') |
|
560 |
||
561 |
def test_get_repository_transport(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
562 |
dir = self.make_controldir('.') |
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
563 |
# without a format, get_repository_transport gives use a transport
|
564 |
# which -may- point to an existing dir.
|
|
565 |
self.assertTrue(isinstance(dir.get_repository_transport(None), |
|
566 |
transport.Transport)) |
|
567 |
# with a given format, either the bzr dir supports identifiable
|
|
568 |
# repositories, or it supports anonymous repository formats, but not both.
|
|
569 |
anonymous_format = AnonymousTestRepositoryFormat() |
|
570 |
identifiable_format = IdentifiableTestRepositoryFormat() |
|
571 |
try: |
|
572 |
found_transport = dir.get_repository_transport(anonymous_format) |
|
573 |
self.assertRaises(errors.IncompatibleFormat, |
|
574 |
dir.get_repository_transport, |
|
575 |
identifiable_format) |
|
576 |
except errors.IncompatibleFormat: |
|
577 |
found_transport = dir.get_repository_transport(identifiable_format) |
|
578 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
579 |
# and the dir which has been initialized for us must exist.
|
|
580 |
found_transport.list_dir('.') |
|
581 |
||
582 |
def test_get_workingtree_transport(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
583 |
dir = self.make_controldir('.') |
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
584 |
# without a format, get_workingtree_transport gives use a transport
|
585 |
# which -may- point to an existing dir.
|
|
586 |
self.assertTrue(isinstance(dir.get_workingtree_transport(None), |
|
587 |
transport.Transport)) |
|
588 |
# with a given format, either the bzr dir supports identifiable
|
|
589 |
# trees, or it supports anonymous tree formats, but not both.
|
|
590 |
anonymous_format = AnonymousTestWorkingTreeFormat() |
|
591 |
identifiable_format = IdentifiableTestWorkingTreeFormat() |
|
592 |
try: |
|
593 |
found_transport = dir.get_workingtree_transport(anonymous_format) |
|
594 |
self.assertRaises(errors.IncompatibleFormat, |
|
595 |
dir.get_workingtree_transport, |
|
596 |
identifiable_format) |
|
597 |
except errors.IncompatibleFormat: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
598 |
found_transport = dir.get_workingtree_transport( |
599 |
identifiable_format) |
|
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
600 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
601 |
# and the dir which has been initialized for us must exist.
|
|
602 |
found_transport.list_dir('.') |
|
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
603 |
|
604 |
def assertInitializeEx(self, t, need_meta=False, **kwargs): |
|
605 |
"""Execute initialize_on_transport_ex and check it succeeded correctly. |
|
606 |
||
607 |
This involves checking that the disk objects were created, open with
|
|
608 |
the same format returned, and had the expected disk format.
|
|
609 |
||
610 |
:param t: The transport to initialize on.
|
|
611 |
:param **kwargs: Additional arguments to pass to
|
|
612 |
initialize_on_transport_ex.
|
|
613 |
:return: the resulting repo, control dir tuple.
|
|
614 |
"""
|
|
615 |
if not self.bzrdir_format.is_initializable(): |
|
616 |
raise TestNotApplicable("control dir format is not " |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
617 |
"initializable") |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
618 |
repo, control, require_stacking, repo_policy = \ |
619 |
self.bzrdir_format.initialize_on_transport_ex(t, **kwargs) |
|
620 |
if repo is not None: |
|
621 |
# Repositories are open write-locked
|
|
622 |
self.assertTrue(repo.is_write_locked()) |
|
623 |
self.addCleanup(repo.unlock) |
|
624 |
self.assertIsInstance(control, bzrdir.BzrDir) |
|
625 |
opened = bzrdir.BzrDir.open(t.base) |
|
626 |
expected_format = self.bzrdir_format |
|
627 |
if need_meta and expected_format.fixed_components: |
|
628 |
# Pre-metadir formats change when we are making something that
|
|
629 |
# needs a metaformat, because clone is used for push.
|
|
630 |
expected_format = bzrdir.BzrDirMetaFormat1() |
|
631 |
if not isinstance(expected_format, RemoteBzrDirFormat): |
|
632 |
self.assertEqual(control._format.network_name(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
633 |
expected_format.network_name()) |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
634 |
self.assertEqual(control._format.network_name(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
635 |
opened._format.network_name()) |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
636 |
self.assertEqual(control.__class__, opened.__class__) |
637 |
return repo, control |
|
638 |
||
639 |
def test_format_initialize_on_transport_ex_default_stack_on(self): |
|
640 |
# When initialize_on_transport_ex uses a stacked-on branch because of
|
|
641 |
# a stacking policy on the target, the location of the fallback
|
|
642 |
# repository is the same as the external location of the stacked-on
|
|
643 |
# branch.
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
644 |
balloon = self.make_controldir('balloon') |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
645 |
if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1): |
646 |
stack_on = self.make_branch('stack-on', format='1.9') |
|
647 |
else: |
|
648 |
stack_on = self.make_branch('stack-on') |
|
6164.2.10
by Jelmer Vernooij
Merge more-foreign-tests-fixes-7 |
649 |
if not stack_on.repository._format.supports_nesting_repositories: |
650 |
raise TestNotApplicable("requires nesting repositories") |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
651 |
config = self.make_controldir('.').get_config() |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
652 |
try: |
653 |
config.set_default_stack_on('stack-on') |
|
654 |
except errors.BzrError: |
|
655 |
raise TestNotApplicable('Only relevant for stackable formats.') |
|
656 |
# Initialize a bzrdir subject to the policy.
|
|
657 |
t = self.get_transport('stacked') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
658 |
repo_fmt = controldir.format_registry.make_controldir('1.9') |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
659 |
repo_name = repo_fmt.repository_format.network_name() |
660 |
repo, control = self.assertInitializeEx( |
|
661 |
t, need_meta=True, repo_format_name=repo_name, stacked_on=None) |
|
662 |
# self.addCleanup(repo.unlock)
|
|
663 |
# There's one fallback repo, with a public location.
|
|
664 |
self.assertLength(1, repo._fallback_repositories) |
|
665 |
fallback_repo = repo._fallback_repositories[0] |
|
666 |
self.assertEqual( |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
667 |
stack_on.base, fallback_repo.controldir.root_transport.base) |
6164.2.5
by Jelmer Vernooij
Move some stacking tests specific to bzr formats to per_bzrdir. |
668 |
# The bzrdir creates a branch in stacking-capable format.
|
669 |
new_branch = control.create_branch() |
|
670 |
self.assertTrue(new_branch._format.supports_stacking()) |
|
671 |
||
6239.1.2
by Jelmer Vernooij
Move test to per_bzrdir. |
672 |
def test_no_leftover_dirs(self): |
673 |
# bug 886196: development-colo uses a branch-lock directory
|
|
674 |
# in the user directory rather than the control directory.
|
|
675 |
if not self.bzrdir_format.colocated_branches: |
|
676 |
raise TestNotApplicable( |
|
677 |
"format does not support colocated branches") |
|
678 |
branch = self.make_branch('.', format='development-colo') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
679 |
branch.controldir.create_branch(name="another-colocated-branch") |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
680 |
self.assertEqual( |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
681 |
branch.controldir.user_transport.list_dir("."), |
6239.1.2
by Jelmer Vernooij
Move test to per_bzrdir. |
682 |
[".bzr"]) |
6282.5.8
by Neil Martinsen-Burrell
refine tests |
683 |
|
684 |
def test_get_branches(self): |
|
685 |
repo = self.make_repository('branch-1') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
686 |
if not repo.controldir._format.colocated_branches: |
6282.5.11
by Jelmer Vernooij
Review tweaks. |
687 |
raise TestNotApplicable('Format does not support colocation') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
688 |
target_branch = repo.controldir.create_branch(name='foo') |
689 |
repo.controldir.set_branch_reference(target_branch) |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
690 |
self.assertEqual({"", 'foo'}, |
7490.13.2
by Jelmer Vernooij
Fix reference handling. |
691 |
set(repo.controldir.branch_names())) |