bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1 |
# (C) 2005, 2006 Canonical Ltd
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for bzrdir implementations - tests a bzrdir format."""
|
|
18 |
||
19 |
import os |
|
|
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. |
20 |
from stat import * |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
21 |
import sys |
22 |
||
|
1508.1.25
by Robert Collins
Update per review comments. |
23 |
import bzrlib.branch |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
24 |
import bzrlib.bzrdir as bzrdir |
25 |
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
26 |
from bzrlib.check import check |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
27 |
from bzrlib.commit import commit |
28 |
import bzrlib.errors as errors |
|
29 |
from bzrlib.errors import (FileExists, |
|
30 |
NoSuchRevision, |
|
31 |
NoSuchFile, |
|
32 |
UninitializableFormat, |
|
33 |
NotBranchError, |
|
34 |
)
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
35 |
import bzrlib.repository as repository |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
36 |
from bzrlib.tests import ( |
37 |
ChrootedTestCase, |
|
38 |
TestCase, |
|
39 |
TestCaseWithTransport, |
|
40 |
TestSkipped, |
|
41 |
)
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
42 |
from bzrlib.trace import mutter |
43 |
import bzrlib.transactions as transactions |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
44 |
import bzrlib.transport as transport |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
45 |
from bzrlib.transport import get_transport |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
46 |
import bzrlib.ui as ui |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
47 |
from bzrlib.upgrade import upgrade |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
48 |
import bzrlib.workingtree as workingtree |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
49 |
|
50 |
||
51 |
class TestCaseWithBzrDir(TestCaseWithTransport): |
|
52 |
||
53 |
def setUp(self): |
|
54 |
super(TestCaseWithBzrDir, self).setUp() |
|
55 |
self.bzrdir = None |
|
56 |
||
57 |
def get_bzrdir(self): |
|
58 |
if self.bzrdir is None: |
|
59 |
self.bzrdir = self.make_bzrdir(None) |
|
60 |
return self.bzrdir |
|
61 |
||
62 |
def make_bzrdir(self, relpath): |
|
63 |
try: |
|
64 |
url = self.get_url(relpath) |
|
65 |
segments = url.split('/') |
|
66 |
if segments and segments[-1] not in ('', '.'): |
|
67 |
parent = '/'.join(segments[:-1]) |
|
68 |
t = get_transport(parent) |
|
69 |
try: |
|
70 |
t.mkdir(segments[-1]) |
|
71 |
except FileExists: |
|
72 |
pass
|
|
73 |
return self.bzrdir_format.initialize(url) |
|
74 |
except UninitializableFormat: |
|
75 |
raise TestSkipped("Format %s is not initializable.") |
|
76 |
||
77 |
||
78 |
class TestBzrDir(TestCaseWithBzrDir): |
|
|
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. |
79 |
# Many of these tests test for disk equality rather than checking
|
80 |
# for semantic equivalence. This works well for some tests but
|
|
81 |
# is not good at handling changes in representation or the addition
|
|
82 |
# or removal of control data. It would be nice to for instance:
|
|
83 |
# sprout a new branch, check that the nickname has been reset by hand
|
|
84 |
# and then set the nickname to match the source branch, at which point
|
|
85 |
# a semantic equivalence should pass
|
|
86 |
||
87 |
def assertDirectoriesEqual(self, source, target, ignore_list=[]): |
|
88 |
"""Assert that the content of source and target are identical. |
|
89 |
||
90 |
paths in ignore list will be completely ignored.
|
|
91 |
"""
|
|
92 |
files = [] |
|
93 |
directories = ['.'] |
|
94 |
while directories: |
|
95 |
dir = directories.pop() |
|
96 |
for path in source.list_dir(dir): |
|
97 |
path = dir + '/' + path |
|
98 |
if path in ignore_list: |
|
99 |
continue
|
|
100 |
stat = source.stat(path) |
|
101 |
if S_ISDIR(stat.st_mode): |
|
102 |
self.assertTrue(S_ISDIR(target.stat(path).st_mode)) |
|
103 |
directories.append(path) |
|
104 |
else: |
|
105 |
self.assertEqualDiff(source.get(path).read(), |
|
106 |
target.get(path).read(), |
|
107 |
"text for file %r differs:\n" % path) |
|
108 |
||
109 |
def test_clone_bzrdir_empty(self): |
|
110 |
dir = self.make_bzrdir('source') |
|
111 |
target = dir.clone(self.get_url('target')) |
|
112 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
113 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
114 |
||
|
1534.6.8
by Robert Collins
Test the use of clone on empty bzrdir with force_new_repo. |
115 |
def test_clone_bzrdir_empty_force_new_ignored(self): |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
116 |
# the force_new_repo parameter should have no effect on an empty
|
|
1534.6.8
by Robert Collins
Test the use of clone on empty bzrdir with force_new_repo. |
117 |
# bzrdir's clone logic
|
118 |
dir = self.make_bzrdir('source') |
|
119 |
target = dir.clone(self.get_url('target'), force_new_repo=True) |
|
120 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
121 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
122 |
||
|
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. |
123 |
def test_clone_bzrdir_repository(self): |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
124 |
tree = self.make_branch_and_tree('commit_tree') |
125 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
126 |
tree.add('foo') |
|
127 |
tree.commit('revision 1', rev_id='1') |
|
|
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. |
128 |
dir = self.make_bzrdir('source') |
129 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
130 |
repo.fetch(tree.branch.repository) |
131 |
self.assertTrue(repo.has_revision('1')) |
|
|
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. |
132 |
target = dir.clone(self.get_url('target')) |
133 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
134 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
135 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
136 |
def test_clone_bzrdir_repository_under_shared(self): |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
137 |
tree = self.make_branch_and_tree('commit_tree') |
138 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
139 |
tree.add('foo') |
|
140 |
tree.commit('revision 1', rev_id='1') |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
141 |
dir = self.make_bzrdir('source') |
142 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
143 |
repo.fetch(tree.branch.repository) |
144 |
self.assertTrue(repo.has_revision('1')) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
145 |
try: |
146 |
self.make_repository('target', shared=True) |
|
147 |
except errors.IncompatibleFormat: |
|
148 |
return
|
|
149 |
target = dir.clone(self.get_url('target/child')) |
|
150 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
151 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
|
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
152 |
|
153 |
def test_clone_bzrdir_repository_branch_both_under_shared(self): |
|
154 |
try: |
|
155 |
shared_repo = self.make_repository('shared', shared=True) |
|
156 |
except errors.IncompatibleFormat: |
|
157 |
return
|
|
158 |
tree = self.make_branch_and_tree('commit_tree') |
|
159 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
160 |
tree.add('foo') |
|
161 |
tree.commit('revision 1', rev_id='1') |
|
162 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
163 |
tree.set_last_revision(None) |
|
164 |
tree.commit('revision 2', rev_id='2') |
|
165 |
tree.bzrdir.open_repository().copy_content_into(shared_repo) |
|
166 |
dir = self.make_bzrdir('shared/source') |
|
167 |
dir.create_branch() |
|
168 |
target = dir.clone(self.get_url('shared/target')) |
|
169 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
170 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
171 |
self.assertTrue(shared_repo.has_revision('1')) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
172 |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
173 |
def test_clone_bzrdir_repository_under_shared_force_new_repo(self): |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
174 |
tree = self.make_branch_and_tree('commit_tree') |
175 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
176 |
tree.add('foo') |
|
177 |
tree.commit('revision 1', rev_id='1') |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
178 |
dir = self.make_bzrdir('source') |
179 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
180 |
repo.fetch(tree.branch.repository) |
181 |
self.assertTrue(repo.has_revision('1')) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
182 |
try: |
183 |
self.make_repository('target', shared=True) |
|
184 |
except errors.IncompatibleFormat: |
|
185 |
return
|
|
186 |
target = dir.clone(self.get_url('target/child'), force_new_repo=True) |
|
187 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
188 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
189 |
||
|
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. |
190 |
def test_clone_bzrdir_repository_revision(self): |
191 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
192 |
# make a repository with some revisions,
|
|
193 |
# and clone it with a revision limit.
|
|
194 |
#
|
|
195 |
tree = self.make_branch_and_tree('commit_tree') |
|
196 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
197 |
tree.add('foo') |
|
198 |
tree.commit('revision 1', rev_id='1') |
|
199 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
200 |
tree.set_last_revision(None) |
|
201 |
tree.commit('revision 2', rev_id='2') |
|
202 |
source = self.make_repository('source') |
|
203 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
204 |
dir = source.bzrdir |
|
205 |
target = dir.clone(self.get_url('target'), revision_id='2') |
|
206 |
raise TestSkipped('revision limiting not strict yet') |
|
207 |
||
208 |
def test_clone_bzrdir_branch_and_repo(self): |
|
209 |
tree = self.make_branch_and_tree('commit_tree') |
|
210 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
211 |
tree.add('foo') |
|
212 |
tree.commit('revision 1') |
|
213 |
source = self.make_branch('source') |
|
214 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
215 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
216 |
dir = source.bzrdir |
|
217 |
target = dir.clone(self.get_url('target')) |
|
218 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
219 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
220 |
['./.bzr/stat-cache', './.bzr/checkout/stat-cache']) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
221 |
|
222 |
def test_clone_bzrdir_branch_and_repo_into_shared_repo(self): |
|
223 |
# by default cloning into a shared repo uses the shared repo.
|
|
224 |
tree = self.make_branch_and_tree('commit_tree') |
|
225 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
226 |
tree.add('foo') |
|
227 |
tree.commit('revision 1') |
|
228 |
source = self.make_branch('source') |
|
229 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
230 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
231 |
try: |
|
232 |
self.make_repository('target', shared=True) |
|
233 |
except errors.IncompatibleFormat: |
|
234 |
return
|
|
235 |
dir = source.bzrdir |
|
236 |
target = dir.clone(self.get_url('target/child')) |
|
237 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
238 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
|
239 |
self.assertEqual(source.revision_history(), |
|
240 |
target.open_branch().revision_history()) |
|
241 |
||
242 |
def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self): |
|
243 |
# by default cloning into a shared repo uses the shared repo.
|
|
244 |
tree = self.make_branch_and_tree('commit_tree') |
|
245 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
246 |
tree.add('foo') |
|
247 |
tree.commit('revision 1') |
|
248 |
source = self.make_branch('source') |
|
249 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
250 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
251 |
try: |
|
252 |
self.make_repository('target', shared=True) |
|
253 |
except errors.IncompatibleFormat: |
|
254 |
return
|
|
255 |
dir = source.bzrdir |
|
256 |
target = dir.clone(self.get_url('target/child'), force_new_repo=True) |
|
257 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
258 |
target.open_repository() |
|
|
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. |
259 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
260 |
||
261 |
def test_clone_bzrdir_branch_reference(self): |
|
262 |
# cloning should preserve the reference status of the branch in a bzrdir
|
|
263 |
referenced_branch = self.make_branch('referencced') |
|
264 |
dir = self.make_bzrdir('source') |
|
265 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
266 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
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. |
267 |
referenced_branch) |
268 |
except errors.IncompatibleFormat: |
|
269 |
# this is ok too, not all formats have to support references.
|
|
270 |
return
|
|
271 |
target = dir.clone(self.get_url('target')) |
|
272 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
273 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
274 |
||
275 |
def test_clone_bzrdir_branch_revision(self): |
|
276 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
277 |
# make a branch with some revisions,
|
|
278 |
# and clone it with a revision limit.
|
|
279 |
#
|
|
280 |
tree = self.make_branch_and_tree('commit_tree') |
|
281 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
282 |
tree.add('foo') |
|
283 |
tree.commit('revision 1', rev_id='1') |
|
284 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
285 |
source = self.make_branch('source') |
|
286 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
287 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
288 |
dir = source.bzrdir |
|
289 |
target = dir.clone(self.get_url('target'), revision_id='1') |
|
290 |
self.assertEqual('1', target.open_branch().last_revision()) |
|
291 |
||
292 |
def test_clone_bzrdir_tree_branch_repo(self): |
|
293 |
tree = self.make_branch_and_tree('sourcce') |
|
294 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
295 |
tree.add('foo') |
|
296 |
tree.commit('revision 1') |
|
297 |
dir = tree.bzrdir |
|
298 |
target = dir.clone(self.get_url('target')) |
|
299 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
300 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
1508.1.20
by Robert Collins
Create a checkout command. |
301 |
['./.bzr/stat-cache', './.bzr/checkout/stat-cache']) |
|
1534.7.175
by Aaron Bentley
Ensured revert writes a normal inventory |
302 |
target.open_workingtree().revert([]) |
303 |
||
304 |
def test_revert_inventory(self): |
|
305 |
tree = self.make_branch_and_tree('sourcce') |
|
306 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
307 |
tree.add('foo') |
|
308 |
tree.commit('revision 1') |
|
309 |
dir = tree.bzrdir |
|
310 |
target = dir.clone(self.get_url('target')) |
|
311 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
312 |
['./.bzr/stat-cache', './.bzr/checkout/stat-cache']) |
|
313 |
target.open_workingtree().revert([]) |
|
314 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
315 |
['./.bzr/stat-cache', './.bzr/checkout/stat-cache']) |
|
|
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. |
316 |
|
317 |
def test_clone_bzrdir_tree_branch_reference(self): |
|
318 |
# a tree with a branch reference (aka a checkout)
|
|
319 |
# should stay a checkout on clone.
|
|
320 |
referenced_branch = self.make_branch('referencced') |
|
321 |
dir = self.make_bzrdir('source') |
|
322 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
323 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
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. |
324 |
referenced_branch) |
325 |
except errors.IncompatibleFormat: |
|
326 |
# this is ok too, not all formats have to support references.
|
|
327 |
return
|
|
328 |
dir.create_workingtree() |
|
329 |
target = dir.clone(self.get_url('target')) |
|
330 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
331 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
1508.1.20
by Robert Collins
Create a checkout command. |
332 |
['./.bzr/stat-cache', './.bzr/checkout/stat-cache']) |
|
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 |
|
334 |
def test_clone_bzrdir_tree_revision(self): |
|
335 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
336 |
# make a tree with a revision with a last-revision
|
|
337 |
# and clone it with a revision limit.
|
|
338 |
# This smoke test just checks the revision-id is right. Tree specific
|
|
339 |
# tests will check corner cases.
|
|
340 |
tree = self.make_branch_and_tree('source') |
|
341 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
342 |
tree.add('foo') |
|
343 |
tree.commit('revision 1', rev_id='1') |
|
344 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
345 |
dir = tree.bzrdir |
|
346 |
target = dir.clone(self.get_url('target'), revision_id='1') |
|
347 |
self.assertEqual('1', target.open_workingtree().last_revision()) |
|
348 |
||
349 |
def test_clone_bzrdir_incomplete_source_with_basis(self): |
|
350 |
# ensure that basis really does grab from the basis by having incomplete source
|
|
351 |
tree = self.make_branch_and_tree('commit_tree') |
|
352 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
353 |
tree.add('foo') |
|
354 |
tree.commit('revision 1', rev_id='1') |
|
355 |
source = self.make_branch_and_tree('source') |
|
356 |
# this gives us an incomplete repository
|
|
357 |
tree.bzrdir.open_repository().copy_content_into(source.branch.repository) |
|
358 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
359 |
tree.bzrdir.open_branch().copy_content_into(source.branch) |
|
360 |
tree.copy_content_into(source) |
|
361 |
self.assertFalse(source.branch.repository.has_revision('2')) |
|
362 |
dir = source.bzrdir |
|
363 |
target = dir.clone(self.get_url('target'), basis=tree.bzrdir) |
|
364 |
self.assertEqual('2', target.open_branch().last_revision()) |
|
365 |
self.assertEqual('2', target.open_workingtree().last_revision()) |
|
366 |
self.assertTrue(target.open_branch().repository.has_revision('2')) |
|
367 |
||
368 |
def test_sprout_bzrdir_empty(self): |
|
369 |
dir = self.make_bzrdir('source') |
|
370 |
target = dir.sprout(self.get_url('target')) |
|
371 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
372 |
# creates a new repository branch and tree
|
|
373 |
target.open_repository() |
|
374 |
target.open_branch() |
|
375 |
target.open_workingtree() |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
376 |
|
377 |
def test_sprout_bzrdir_empty_under_shared_repo(self): |
|
378 |
# sprouting an empty dir into a repo uses the repo
|
|
379 |
dir = self.make_bzrdir('source') |
|
380 |
try: |
|
381 |
self.make_repository('target', shared=True) |
|
382 |
except errors.IncompatibleFormat: |
|
383 |
return
|
|
384 |
target = dir.sprout(self.get_url('target/child')) |
|
385 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
|
386 |
target.open_branch() |
|
387 |
target.open_workingtree() |
|
388 |
||
389 |
def test_sprout_bzrdir_empty_under_shared_repo(self): |
|
390 |
# the force_new_repo parameter should force use of a new repo in an empty
|
|
391 |
# bzrdir's sprout logic
|
|
392 |
dir = self.make_bzrdir('source') |
|
393 |
try: |
|
394 |
self.make_repository('target', shared=True) |
|
395 |
except errors.IncompatibleFormat: |
|
396 |
return
|
|
397 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
|
398 |
target.open_repository() |
|
399 |
target.open_branch() |
|
400 |
target.open_workingtree() |
|
|
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. |
401 |
|
402 |
def test_sprout_bzrdir_repository(self): |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
403 |
tree = self.make_branch_and_tree('commit_tree') |
404 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
405 |
tree.add('foo') |
|
406 |
tree.commit('revision 1', rev_id='1') |
|
|
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. |
407 |
dir = self.make_bzrdir('source') |
408 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
409 |
repo.fetch(tree.branch.repository) |
410 |
self.assertTrue(repo.has_revision('1')) |
|
|
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. |
411 |
target = dir.sprout(self.get_url('target')) |
412 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
413 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport) |
|
414 |
||
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
415 |
def test_sprout_bzrdir_with_repository_to_shared(self): |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
416 |
tree = self.make_branch_and_tree('commit_tree') |
417 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
418 |
tree.add('foo') |
|
419 |
tree.commit('revision 1', rev_id='1') |
|
420 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
421 |
tree.set_last_revision(None) |
|
422 |
tree.commit('revision 2', rev_id='2') |
|
423 |
source = self.make_repository('source') |
|
424 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
425 |
dir = source.bzrdir |
|
426 |
try: |
|
427 |
shared_repo = self.make_repository('target', shared=True) |
|
428 |
except errors.IncompatibleFormat: |
|
429 |
return
|
|
430 |
target = dir.sprout(self.get_url('target/child')) |
|
431 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
432 |
self.assertTrue(shared_repo.has_revision('1')) |
|
433 |
||
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
434 |
def test_sprout_bzrdir_repository_branch_both_under_shared(self): |
435 |
try: |
|
436 |
shared_repo = self.make_repository('shared', shared=True) |
|
437 |
except errors.IncompatibleFormat: |
|
438 |
return
|
|
439 |
tree = self.make_branch_and_tree('commit_tree') |
|
440 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
441 |
tree.add('foo') |
|
442 |
tree.commit('revision 1', rev_id='1') |
|
443 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
444 |
tree.set_last_revision(None) |
|
445 |
tree.commit('revision 2', rev_id='2') |
|
446 |
tree.bzrdir.open_repository().copy_content_into(shared_repo) |
|
447 |
dir = self.make_bzrdir('shared/source') |
|
448 |
dir.create_branch() |
|
449 |
target = dir.sprout(self.get_url('shared/target')) |
|
450 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
451 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
452 |
self.assertTrue(shared_repo.has_revision('1')) |
|
453 |
||
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
454 |
def test_sprout_bzrdir_repository_under_shared_force_new_repo(self): |
455 |
tree = self.make_branch_and_tree('commit_tree') |
|
456 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
457 |
tree.add('foo') |
|
458 |
tree.commit('revision 1', rev_id='1') |
|
459 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
460 |
tree.set_last_revision(None) |
|
461 |
tree.commit('revision 2', rev_id='2') |
|
462 |
source = self.make_repository('source') |
|
463 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
464 |
dir = source.bzrdir |
|
465 |
try: |
|
466 |
shared_repo = self.make_repository('target', shared=True) |
|
467 |
except errors.IncompatibleFormat: |
|
468 |
return
|
|
469 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
|
470 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
471 |
self.assertFalse(shared_repo.has_revision('1')) |
|
472 |
||
|
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. |
473 |
def test_sprout_bzrdir_repository_revision(self): |
474 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
475 |
# make a repository with some revisions,
|
|
476 |
# and sprout it with a revision limit.
|
|
477 |
#
|
|
478 |
tree = self.make_branch_and_tree('commit_tree') |
|
479 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
480 |
tree.add('foo') |
|
481 |
tree.commit('revision 1', rev_id='1') |
|
482 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
483 |
tree.set_last_revision(None) |
|
484 |
tree.commit('revision 2', rev_id='2') |
|
485 |
source = self.make_repository('source') |
|
486 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
487 |
dir = source.bzrdir |
|
488 |
target = dir.sprout(self.get_url('target'), revision_id='2') |
|
489 |
raise TestSkipped('revision limiting not strict yet') |
|
490 |
||
491 |
def test_sprout_bzrdir_branch_and_repo(self): |
|
492 |
tree = self.make_branch_and_tree('commit_tree') |
|
493 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
494 |
tree.add('foo') |
|
495 |
tree.commit('revision 1') |
|
496 |
source = self.make_branch('source') |
|
497 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
498 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
499 |
dir = source.bzrdir |
|
500 |
target = dir.sprout(self.get_url('target')) |
|
501 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
502 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
503 |
['./.bzr/stat-cache', |
|
504 |
'./.bzr/checkout/stat-cache', |
|
505 |
'./.bzr/inventory', |
|
506 |
'./.bzr/checkout/inventory', |
|
507 |
])
|
|
|
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. |
508 |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
509 |
def test_sprout_bzrdir_branch_and_repo_shared(self): |
510 |
# sprouting a branch with a repo into a shared repo uses the shared
|
|
511 |
# repo
|
|
512 |
tree = self.make_branch_and_tree('commit_tree') |
|
513 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
514 |
tree.add('foo') |
|
515 |
tree.commit('revision 1', rev_id='1') |
|
516 |
source = self.make_branch('source') |
|
517 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
518 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
519 |
dir = source.bzrdir |
|
520 |
try: |
|
521 |
shared_repo = self.make_repository('target', shared=True) |
|
522 |
except errors.IncompatibleFormat: |
|
523 |
return
|
|
524 |
target = dir.sprout(self.get_url('target/child')) |
|
525 |
self.assertTrue(shared_repo.has_revision('1')) |
|
526 |
||
527 |
def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self): |
|
528 |
# sprouting a branch with a repo into a shared repo uses the shared
|
|
529 |
# repo
|
|
530 |
tree = self.make_branch_and_tree('commit_tree') |
|
531 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
532 |
tree.add('foo') |
|
533 |
tree.commit('revision 1', rev_id='1') |
|
534 |
source = self.make_branch('source') |
|
535 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
536 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
537 |
dir = source.bzrdir |
|
538 |
try: |
|
539 |
shared_repo = self.make_repository('target', shared=True) |
|
540 |
except errors.IncompatibleFormat: |
|
541 |
return
|
|
542 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
|
543 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
544 |
self.assertFalse(shared_repo.has_revision('1')) |
|
545 |
||
|
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. |
546 |
def test_sprout_bzrdir_branch_reference(self): |
547 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
548 |
referenced_branch = self.make_branch('referencced') |
|
549 |
dir = self.make_bzrdir('source') |
|
550 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
551 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
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. |
552 |
referenced_branch) |
553 |
except errors.IncompatibleFormat: |
|
554 |
# this is ok too, not all formats have to support references.
|
|
555 |
return
|
|
556 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
557 |
target = dir.sprout(self.get_url('target')) |
|
558 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
559 |
# we want target to have a branch that is in-place.
|
|
560 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
561 |
# and as we dont support repositories being detached yet, a repo in
|
|
562 |
# place
|
|
563 |
target.open_repository() |
|
564 |
||
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
565 |
def test_sprout_bzrdir_branch_reference_shared(self): |
566 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
567 |
referenced_tree = self.make_branch_and_tree('referenced') |
|
568 |
referenced_tree.commit('1', rev_id='1', allow_pointless=True) |
|
569 |
dir = self.make_bzrdir('source') |
|
570 |
try: |
|
571 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
572 |
referenced_tree.branch) |
|
573 |
except errors.IncompatibleFormat: |
|
574 |
# this is ok too, not all formats have to support references.
|
|
575 |
return
|
|
576 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
577 |
try: |
|
578 |
shared_repo = self.make_repository('target', shared=True) |
|
579 |
except errors.IncompatibleFormat: |
|
580 |
return
|
|
581 |
target = dir.sprout(self.get_url('target/child')) |
|
582 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
583 |
# we want target to have a branch that is in-place.
|
|
584 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
585 |
# and we want no repository as the target is shared
|
|
586 |
self.assertRaises(errors.NoRepositoryPresent, |
|
587 |
target.open_repository) |
|
588 |
# and we want revision '1' in the shared repo
|
|
589 |
self.assertTrue(shared_repo.has_revision('1')) |
|
590 |
||
591 |
def test_sprout_bzrdir_branch_reference_shared_force_new_repo(self): |
|
592 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
593 |
referenced_tree = self.make_branch_and_tree('referenced') |
|
594 |
referenced_tree.commit('1', rev_id='1', allow_pointless=True) |
|
595 |
dir = self.make_bzrdir('source') |
|
596 |
try: |
|
597 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
598 |
referenced_tree.branch) |
|
599 |
except errors.IncompatibleFormat: |
|
600 |
# this is ok too, not all formats have to support references.
|
|
601 |
return
|
|
602 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
603 |
try: |
|
604 |
shared_repo = self.make_repository('target', shared=True) |
|
605 |
except errors.IncompatibleFormat: |
|
606 |
return
|
|
607 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
|
608 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
609 |
# we want target to have a branch that is in-place.
|
|
610 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
611 |
# and we want revision '1' in the new repo
|
|
612 |
self.assertTrue(target.open_repository().has_revision('1')) |
|
613 |
# but not the shared one
|
|
614 |
self.assertFalse(shared_repo.has_revision('1')) |
|
615 |
||
|
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. |
616 |
def test_sprout_bzrdir_branch_revision(self): |
617 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
618 |
# make a repository with some revisions,
|
|
619 |
# and sprout it with a revision limit.
|
|
620 |
#
|
|
621 |
tree = self.make_branch_and_tree('commit_tree') |
|
622 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
623 |
tree.add('foo') |
|
624 |
tree.commit('revision 1', rev_id='1') |
|
625 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
626 |
source = self.make_branch('source') |
|
627 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
628 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
629 |
dir = source.bzrdir |
|
630 |
target = dir.sprout(self.get_url('target'), revision_id='1') |
|
631 |
self.assertEqual('1', target.open_branch().last_revision()) |
|
632 |
||
633 |
def test_sprout_bzrdir_tree_branch_repo(self): |
|
634 |
tree = self.make_branch_and_tree('sourcce') |
|
635 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
636 |
tree.add('foo') |
|
637 |
tree.commit('revision 1') |
|
638 |
dir = tree.bzrdir |
|
639 |
target = dir.sprout(self.get_url('target')) |
|
640 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
641 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
642 |
['./.bzr/stat-cache', |
643 |
'./.bzr/checkout/stat-cache', |
|
644 |
'./.bzr/inventory', |
|
645 |
'./.bzr/checkout/inventory', |
|
646 |
])
|
|
|
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. |
647 |
|
648 |
def test_sprout_bzrdir_tree_branch_reference(self): |
|
649 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
650 |
# the tree state should not be copied.
|
|
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. |
651 |
referenced_branch = self.make_branch('referencced') |
652 |
dir = self.make_bzrdir('source') |
|
653 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
654 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
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. |
655 |
referenced_branch) |
656 |
except errors.IncompatibleFormat: |
|
657 |
# this is ok too, not all formats have to support references.
|
|
658 |
return
|
|
659 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
660 |
tree = dir.create_workingtree() |
661 |
tree.bzrdir.root_transport.mkdir('subdir') |
|
662 |
tree.add('subdir') |
|
|
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. |
663 |
target = dir.sprout(self.get_url('target')) |
664 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
665 |
# we want target to have a branch that is in-place.
|
|
666 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
667 |
# and as we dont support repositories being detached yet, a repo in
|
|
668 |
# place
|
|
669 |
target.open_repository() |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
670 |
result_tree = target.open_workingtree() |
671 |
self.assertFalse(result_tree.has_filename('subdir')) |
|
|
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. |
672 |
|
673 |
def test_sprout_bzrdir_tree_branch_reference_revision(self): |
|
674 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
675 |
# the tree state should not be copied but the revision changed,
|
|
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. |
676 |
# and the likewise the new branch should be truncated too
|
677 |
referenced_branch = self.make_branch('referencced') |
|
678 |
dir = self.make_bzrdir('source') |
|
679 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
680 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
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. |
681 |
referenced_branch) |
682 |
except errors.IncompatibleFormat: |
|
683 |
# this is ok too, not all formats have to support references.
|
|
684 |
return
|
|
685 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
686 |
tree = dir.create_workingtree() |
|
687 |
self.build_tree(['foo'], transport=dir.root_transport) |
|
688 |
tree.add('foo') |
|
689 |
tree.commit('revision 1', rev_id='1') |
|
690 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
691 |
target = dir.sprout(self.get_url('target'), revision_id='1') |
|
692 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
693 |
# we want target to have a branch that is in-place.
|
|
694 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
695 |
# and as we dont support repositories being detached yet, a repo in
|
|
696 |
# place
|
|
697 |
target.open_repository() |
|
698 |
# we trust that the working tree sprouting works via the other tests.
|
|
699 |
self.assertEqual('1', target.open_workingtree().last_revision()) |
|
700 |
self.assertEqual('1', target.open_branch().last_revision()) |
|
701 |
||
702 |
def test_sprout_bzrdir_tree_revision(self): |
|
703 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
704 |
# make a tree with a revision with a last-revision
|
|
705 |
# and sprout it with a revision limit.
|
|
706 |
# This smoke test just checks the revision-id is right. Tree specific
|
|
707 |
# tests will check corner cases.
|
|
708 |
tree = self.make_branch_and_tree('source') |
|
709 |
self.build_tree(['foo'], transport=tree.bzrdir.root_transport) |
|
710 |
tree.add('foo') |
|
711 |
tree.commit('revision 1', rev_id='1') |
|
712 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
713 |
dir = tree.bzrdir |
|
714 |
target = dir.sprout(self.get_url('target'), revision_id='1') |
|
715 |
self.assertEqual('1', target.open_workingtree().last_revision()) |
|
716 |
||
717 |
def test_sprout_bzrdir_incomplete_source_with_basis(self): |
|
718 |
# ensure that basis really does grab from the basis by having incomplete source
|
|
719 |
tree = self.make_branch_and_tree('commit_tree') |
|
720 |
self.build_tree(['foo'], transport=tree.bzrdir.root_transport) |
|
721 |
tree.add('foo') |
|
722 |
tree.commit('revision 1', rev_id='1') |
|
723 |
source = self.make_branch_and_tree('source') |
|
724 |
# this gives us an incomplete repository
|
|
725 |
tree.bzrdir.open_repository().copy_content_into(source.branch.repository) |
|
726 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
727 |
tree.bzrdir.open_branch().copy_content_into(source.branch) |
|
728 |
tree.copy_content_into(source) |
|
729 |
self.assertFalse(source.branch.repository.has_revision('2')) |
|
730 |
dir = source.bzrdir |
|
731 |
target = dir.sprout(self.get_url('target'), basis=tree.bzrdir) |
|
732 |
self.assertEqual('2', target.open_branch().last_revision()) |
|
733 |
self.assertEqual('2', target.open_workingtree().last_revision()) |
|
734 |
self.assertTrue(target.open_branch().repository.has_revision('2')) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
735 |
|
736 |
def test_format_initialize_find_open(self): |
|
737 |
# loopback test to check the current format initializes to itself.
|
|
738 |
if not self.bzrdir_format.is_supported(): |
|
739 |
# unsupported formats are not loopback testable
|
|
740 |
# because the default open will not open them and
|
|
741 |
# they may not be initializable.
|
|
742 |
return
|
|
743 |
# supported formats must be able to init and open
|
|
744 |
t = get_transport(self.get_url()) |
|
745 |
readonly_t = get_transport(self.get_readonly_url()) |
|
746 |
made_control = self.bzrdir_format.initialize(t.base) |
|
747 |
self.failUnless(isinstance(made_control, bzrdir.BzrDir)) |
|
748 |
self.assertEqual(self.bzrdir_format, |
|
749 |
bzrdir.BzrDirFormat.find_format(readonly_t)) |
|
750 |
direct_opened_dir = self.bzrdir_format.open(readonly_t) |
|
751 |
opened_dir = bzrdir.BzrDir.open(t.base) |
|
752 |
self.assertEqual(made_control._format, |
|
753 |
opened_dir._format) |
|
754 |
self.assertEqual(direct_opened_dir._format, |
|
755 |
opened_dir._format) |
|
756 |
self.failUnless(isinstance(opened_dir, bzrdir.BzrDir)) |
|
757 |
||
758 |
def test_open_not_bzrdir(self): |
|
759 |
# test the formats specific behaviour for no-content or similar dirs.
|
|
760 |
self.assertRaises(NotBranchError, |
|
761 |
self.bzrdir_format.open, |
|
762 |
get_transport(self.get_readonly_url())) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
763 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
764 |
def test_create_branch(self): |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
765 |
# a bzrdir can construct a branch and repository for itself.
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
766 |
if not self.bzrdir_format.is_supported(): |
767 |
# unsupported formats are not loopback testable
|
|
768 |
# because the default open will not open them and
|
|
769 |
# they may not be initializable.
|
|
770 |
return
|
|
771 |
t = get_transport(self.get_url()) |
|
772 |
made_control = self.bzrdir_format.initialize(t.base) |
|
773 |
made_repo = made_control.create_repository() |
|
774 |
made_branch = made_control.create_branch() |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
775 |
self.failUnless(isinstance(made_branch, bzrlib.branch.Branch)) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
776 |
self.assertEqual(made_control, made_branch.bzrdir) |
777 |
||
778 |
def test_open_branch(self): |
|
779 |
if not self.bzrdir_format.is_supported(): |
|
780 |
# unsupported formats are not loopback testable
|
|
781 |
# because the default open will not open them and
|
|
782 |
# they may not be initializable.
|
|
783 |
return
|
|
784 |
t = get_transport(self.get_url()) |
|
785 |
made_control = self.bzrdir_format.initialize(t.base) |
|
786 |
made_repo = made_control.create_repository() |
|
787 |
made_branch = made_control.create_branch() |
|
788 |
opened_branch = made_control.open_branch() |
|
789 |
self.assertEqual(made_control, opened_branch.bzrdir) |
|
790 |
self.failUnless(isinstance(opened_branch, made_branch.__class__)) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
791 |
self.failUnless(isinstance(opened_branch._format, made_branch._format.__class__)) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
792 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
793 |
def test_create_repository(self): |
794 |
# a bzrdir can construct a repository for itself.
|
|
795 |
if not self.bzrdir_format.is_supported(): |
|
796 |
# unsupported formats are not loopback testable
|
|
797 |
# because the default open will not open them and
|
|
798 |
# they may not be initializable.
|
|
799 |
return
|
|
800 |
t = get_transport(self.get_url()) |
|
801 |
made_control = self.bzrdir_format.initialize(t.base) |
|
802 |
made_repo = made_control.create_repository() |
|
803 |
self.failUnless(isinstance(made_repo, repository.Repository)) |
|
804 |
self.assertEqual(made_control, made_repo.bzrdir) |
|
805 |
||
806 |
def test_open_repository(self): |
|
807 |
if not self.bzrdir_format.is_supported(): |
|
808 |
# unsupported formats are not loopback testable
|
|
809 |
# because the default open will not open them and
|
|
810 |
# they may not be initializable.
|
|
811 |
return
|
|
812 |
t = get_transport(self.get_url()) |
|
813 |
made_control = self.bzrdir_format.initialize(t.base) |
|
814 |
made_repo = made_control.create_repository() |
|
815 |
opened_repo = made_control.open_repository() |
|
816 |
self.assertEqual(made_control, opened_repo.bzrdir) |
|
817 |
self.failUnless(isinstance(opened_repo, made_repo.__class__)) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
818 |
self.failUnless(isinstance(opened_repo._format, made_repo._format.__class__)) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
819 |
|
820 |
def test_create_workingtree(self): |
|
821 |
# a bzrdir can construct a working tree for itself.
|
|
822 |
if not self.bzrdir_format.is_supported(): |
|
823 |
# unsupported formats are not loopback testable
|
|
824 |
# because the default open will not open them and
|
|
825 |
# they may not be initializable.
|
|
826 |
return
|
|
827 |
# this has to be tested with local access as we still support creating
|
|
828 |
# format 6 bzrdirs
|
|
829 |
t = get_transport('.') |
|
830 |
made_control = self.bzrdir_format.initialize(t.base) |
|
831 |
made_repo = made_control.create_repository() |
|
832 |
made_branch = made_control.create_branch() |
|
833 |
made_tree = made_control.create_workingtree() |
|
834 |
self.failUnless(isinstance(made_tree, workingtree.WorkingTree)) |
|
835 |
self.assertEqual(made_control, made_tree.bzrdir) |
|
836 |
||
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
837 |
def test_create_workingtree_revision(self): |
838 |
# a bzrdir can construct a working tree for itself @ a specific revision.
|
|
839 |
source = self.make_branch_and_tree('source') |
|
840 |
source.commit('a', rev_id='a', allow_pointless=True) |
|
841 |
source.commit('b', rev_id='b', allow_pointless=True) |
|
842 |
self.build_tree(['new/']) |
|
843 |
made_control = self.bzrdir_format.initialize('new') |
|
844 |
source.branch.repository.clone(made_control) |
|
845 |
source.branch.clone(made_control) |
|
846 |
made_tree = made_control.create_workingtree(revision_id='a') |
|
847 |
self.assertEqual('a', made_tree.last_revision()) |
|
848 |
||
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
849 |
def test_open_workingtree(self): |
850 |
if not self.bzrdir_format.is_supported(): |
|
851 |
# unsupported formats are not loopback testable
|
|
852 |
# because the default open will not open them and
|
|
853 |
# they may not be initializable.
|
|
854 |
return
|
|
855 |
# this has to be tested with local access as we still support creating
|
|
856 |
# format 6 bzrdirs
|
|
857 |
t = get_transport('.') |
|
858 |
made_control = self.bzrdir_format.initialize(t.base) |
|
859 |
made_repo = made_control.create_repository() |
|
860 |
made_branch = made_control.create_branch() |
|
861 |
made_tree = made_control.create_workingtree() |
|
862 |
opened_tree = made_control.open_workingtree() |
|
863 |
self.assertEqual(made_control, opened_tree.bzrdir) |
|
864 |
self.failUnless(isinstance(opened_tree, made_tree.__class__)) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
865 |
self.failUnless(isinstance(opened_tree._format, made_tree._format.__class__)) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
866 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
867 |
def test_get_branch_transport(self): |
868 |
dir = self.make_bzrdir('.') |
|
869 |
# without a format, get_branch_transport gives use a transport
|
|
870 |
# which -may- point to an existing dir.
|
|
871 |
self.assertTrue(isinstance(dir.get_branch_transport(None), |
|
872 |
transport.Transport)) |
|
873 |
# with a given format, either the bzr dir supports identifiable
|
|
874 |
# branches, or it supports anonymous branch formats, but not both.
|
|
|
1508.1.25
by Robert Collins
Update per review comments. |
875 |
anonymous_format = bzrlib.branch.BzrBranchFormat4() |
876 |
identifiable_format = bzrlib.branch.BzrBranchFormat5() |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
877 |
try: |
878 |
found_transport = dir.get_branch_transport(anonymous_format) |
|
879 |
self.assertRaises(errors.IncompatibleFormat, |
|
880 |
dir.get_branch_transport, |
|
881 |
identifiable_format) |
|
882 |
except errors.IncompatibleFormat: |
|
883 |
found_transport = dir.get_branch_transport(identifiable_format) |
|
884 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
885 |
# and the dir which has been initialized for us must be statable.
|
|
886 |
found_transport.stat('.') |
|
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
887 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
888 |
def test_get_repository_transport(self): |
889 |
dir = self.make_bzrdir('.') |
|
890 |
# without a format, get_repository_transport gives use a transport
|
|
891 |
# which -may- point to an existing dir.
|
|
892 |
self.assertTrue(isinstance(dir.get_repository_transport(None), |
|
893 |
transport.Transport)) |
|
894 |
# with a given format, either the bzr dir supports identifiable
|
|
895 |
# repositoryes, or it supports anonymous repository formats, but not both.
|
|
896 |
anonymous_format = repository.RepositoryFormat6() |
|
897 |
identifiable_format = repository.RepositoryFormat7() |
|
898 |
try: |
|
899 |
found_transport = dir.get_repository_transport(anonymous_format) |
|
900 |
self.assertRaises(errors.IncompatibleFormat, |
|
901 |
dir.get_repository_transport, |
|
902 |
identifiable_format) |
|
903 |
except errors.IncompatibleFormat: |
|
904 |
found_transport = dir.get_repository_transport(identifiable_format) |
|
905 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
906 |
# and the dir which has been initialized for us must be statable.
|
|
907 |
found_transport.stat('.') |
|
908 |
||
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
909 |
def test_get_workingtree_transport(self): |
910 |
dir = self.make_bzrdir('.') |
|
911 |
# without a format, get_workingtree_transport gives use a transport
|
|
912 |
# which -may- point to an existing dir.
|
|
913 |
self.assertTrue(isinstance(dir.get_workingtree_transport(None), |
|
914 |
transport.Transport)) |
|
915 |
# with a given format, either the bzr dir supports identifiable
|
|
916 |
# trees, or it supports anonymous tree formats, but not both.
|
|
917 |
anonymous_format = workingtree.WorkingTreeFormat2() |
|
918 |
identifiable_format = workingtree.WorkingTreeFormat3() |
|
919 |
try: |
|
920 |
found_transport = dir.get_workingtree_transport(anonymous_format) |
|
921 |
self.assertRaises(errors.IncompatibleFormat, |
|
922 |
dir.get_workingtree_transport, |
|
923 |
identifiable_format) |
|
924 |
except errors.IncompatibleFormat: |
|
925 |
found_transport = dir.get_workingtree_transport(identifiable_format) |
|
926 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
927 |
# and the dir which has been initialized for us must be statable.
|
|
928 |
found_transport.stat('.') |
|
|
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. |
929 |
|
930 |
def test_root_transport(self): |
|
931 |
dir = self.make_bzrdir('.') |
|
932 |
self.assertEqual(dir.root_transport.base, |
|
933 |
get_transport(self.get_url('.')).base) |
|
934 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
935 |
def test_find_repository_no_repo_under_standalone_branch(self): |
936 |
# finding a repo stops at standalone branches even if there is a
|
|
937 |
# higher repository available.
|
|
938 |
try: |
|
939 |
repo = self.make_repository('.', shared=True) |
|
940 |
except errors.IncompatibleFormat: |
|
941 |
# need a shared repository to test this.
|
|
942 |
return
|
|
943 |
url = self.get_url('intermediate') |
|
944 |
get_transport(self.get_url()).mkdir('intermediate') |
|
945 |
get_transport(self.get_url()).mkdir('intermediate/child') |
|
946 |
made_control = self.bzrdir_format.initialize(url) |
|
947 |
made_control.create_repository() |
|
948 |
innermost_control = self.bzrdir_format.initialize( |
|
949 |
self.get_url('intermediate/child')) |
|
950 |
try: |
|
951 |
child_repo = innermost_control.open_repository() |
|
952 |
# if there is a repository, then the format cannot ever hit this
|
|
953 |
# code path.
|
|
954 |
return
|
|
955 |
except errors.NoRepositoryPresent: |
|
956 |
pass
|
|
957 |
self.assertRaises(errors.NoRepositoryPresent, |
|
958 |
innermost_control.find_repository) |
|
959 |
||
960 |
def test_find_repository_containing_shared_repository(self): |
|
961 |
# find repo inside a shared repo with an empty control dir
|
|
962 |
# returns the shared repo.
|
|
963 |
try: |
|
964 |
repo = self.make_repository('.', shared=True) |
|
965 |
except errors.IncompatibleFormat: |
|
966 |
# need a shared repository to test this.
|
|
967 |
return
|
|
968 |
url = self.get_url('childbzrdir') |
|
969 |
get_transport(self.get_url()).mkdir('childbzrdir') |
|
970 |
made_control = self.bzrdir_format.initialize(url) |
|
971 |
try: |
|
972 |
child_repo = made_control.open_repository() |
|
973 |
# if there is a repository, then the format cannot ever hit this
|
|
974 |
# code path.
|
|
975 |
return
|
|
976 |
except errors.NoRepositoryPresent: |
|
977 |
pass
|
|
978 |
found_repo = made_control.find_repository() |
|
979 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
980 |
found_repo.bzrdir.root_transport.base) |
|
981 |
||
982 |
def test_find_repository_standalone_with_containing_shared_repository(self): |
|
983 |
# find repo inside a standalone repo inside a shared repo finds the standalone repo
|
|
984 |
try: |
|
985 |
containing_repo = self.make_repository('.', shared=True) |
|
986 |
except errors.IncompatibleFormat: |
|
987 |
# need a shared repository to test this.
|
|
988 |
return
|
|
989 |
child_repo = self.make_repository('childrepo') |
|
990 |
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo')) |
|
991 |
found_repo = opened_control.find_repository() |
|
992 |
self.assertEqual(child_repo.bzrdir.root_transport.base, |
|
993 |
found_repo.bzrdir.root_transport.base) |
|
994 |
||
995 |
def test_find_repository_shared_within_shared_repository(self): |
|
996 |
# find repo at a shared repo inside a shared repo finds the inner repo
|
|
997 |
try: |
|
998 |
containing_repo = self.make_repository('.', shared=True) |
|
999 |
except errors.IncompatibleFormat: |
|
1000 |
# need a shared repository to test this.
|
|
1001 |
return
|
|
1002 |
url = self.get_url('childrepo') |
|
1003 |
get_transport(self.get_url()).mkdir('childrepo') |
|
1004 |
child_control = self.bzrdir_format.initialize(url) |
|
1005 |
child_repo = child_control.create_repository(shared=True) |
|
1006 |
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo')) |
|
1007 |
found_repo = opened_control.find_repository() |
|
1008 |
self.assertEqual(child_repo.bzrdir.root_transport.base, |
|
1009 |
found_repo.bzrdir.root_transport.base) |
|
1010 |
self.assertNotEqual(child_repo.bzrdir.root_transport.base, |
|
1011 |
containing_repo.bzrdir.root_transport.base) |
|
1012 |
||
1013 |
def test_find_repository_with_nested_dirs_works(self): |
|
1014 |
# find repo inside a bzrdir inside a bzrdir inside a shared repo
|
|
1015 |
# finds the outer shared repo.
|
|
1016 |
try: |
|
1017 |
repo = self.make_repository('.', shared=True) |
|
1018 |
except errors.IncompatibleFormat: |
|
1019 |
# need a shared repository to test this.
|
|
1020 |
return
|
|
1021 |
url = self.get_url('intermediate') |
|
1022 |
get_transport(self.get_url()).mkdir('intermediate') |
|
1023 |
get_transport(self.get_url()).mkdir('intermediate/child') |
|
1024 |
made_control = self.bzrdir_format.initialize(url) |
|
1025 |
try: |
|
1026 |
child_repo = made_control.open_repository() |
|
1027 |
# if there is a repository, then the format cannot ever hit this
|
|
1028 |
# code path.
|
|
1029 |
return
|
|
1030 |
except errors.NoRepositoryPresent: |
|
1031 |
pass
|
|
1032 |
innermost_control = self.bzrdir_format.initialize( |
|
1033 |
self.get_url('intermediate/child')) |
|
1034 |
try: |
|
1035 |
child_repo = innermost_control.open_repository() |
|
1036 |
# if there is a repository, then the format cannot ever hit this
|
|
1037 |
# code path.
|
|
1038 |
return
|
|
1039 |
except errors.NoRepositoryPresent: |
|
1040 |
pass
|
|
1041 |
found_repo = innermost_control.find_repository() |
|
1042 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
1043 |
found_repo.bzrdir.root_transport.base) |
|
1044 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1045 |
def test_can_and_needs_format_conversion(self): |
|
1534.5.8
by Robert Collins
Ensure that bzrdir implementations offer the can_update_format and needs_format_update api. |
1046 |
# check that we can ask an instance if its upgradable
|
1047 |
dir = self.make_bzrdir('.') |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1048 |
if dir.can_convert_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. |
1049 |
# if its default updatable there must be an updater
|
1050 |
# (we change the default to match the lastest known format
|
|
1051 |
# as downgrades may not be available
|
|
1052 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
1053 |
bzrdir.BzrDirFormat.set_default_format(dir._format) |
|
1054 |
try: |
|
1055 |
self.assertTrue(isinstance(dir._format.get_converter(), |
|
1056 |
bzrdir.Converter)) |
|
1057 |
finally: |
|
1058 |
bzrdir.BzrDirFormat.set_default_format(old_format) |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1059 |
dir.needs_format_conversion(None) |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1060 |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1061 |
def test_upgrade_new_instance(self): |
1062 |
"""Does an available updater work ?.""" |
|
1063 |
dir = self.make_bzrdir('.') |
|
|
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. |
1064 |
# for now, check is not ready for partial bzrdirs.
|
1065 |
dir.create_repository() |
|
1066 |
dir.create_branch() |
|
1067 |
dir.create_workingtree() |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1068 |
if dir.can_convert_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. |
1069 |
# if its default updatable there must be an updater
|
1070 |
# (we change the default to match the lastest known format
|
|
1071 |
# as downgrades may not be available
|
|
1072 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
1073 |
bzrdir.BzrDirFormat.set_default_format(dir._format) |
|
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1074 |
pb = ui.ui_factory.nested_progress_bar() |
|
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. |
1075 |
try: |
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1076 |
dir._format.get_converter(None).convert(dir, pb) |
|
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. |
1077 |
finally: |
1078 |
bzrdir.BzrDirFormat.set_default_format(old_format) |
|
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1079 |
pb.finished() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1080 |
# and it should pass 'check' now.
|
1081 |
check(bzrdir.BzrDir.open(self.get_url('.')).open_branch(), False) |
|
1082 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1083 |
def test_format_description(self): |
1084 |
dir = self.make_bzrdir('.') |
|
1085 |
text = dir._format.get_format_description() |
|
1086 |
self.failUnless(len(text)) |
|
1087 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1088 |
|
1089 |
class ChrootedBzrDirTests(ChrootedTestCase): |
|
1090 |
||
1091 |
def test_find_repository_no_repository(self): |
|
1092 |
# loopback test to check the current format fails to find a
|
|
1093 |
# share repository correctly.
|
|
1094 |
if not self.bzrdir_format.is_supported(): |
|
1095 |
# unsupported formats are not loopback testable
|
|
1096 |
# because the default open will not open them and
|
|
1097 |
# they may not be initializable.
|
|
1098 |
return
|
|
1099 |
# supported formats must be able to init and open
|
|
1100 |
url = self.get_url('subdir') |
|
1101 |
get_transport(self.get_url()).mkdir('subdir') |
|
1102 |
made_control = self.bzrdir_format.initialize(url) |
|
1103 |
try: |
|
1104 |
repo = made_control.open_repository() |
|
1105 |
# if there is a repository, then the format cannot ever hit this
|
|
1106 |
# code path.
|
|
1107 |
return
|
|
1108 |
except errors.NoRepositoryPresent: |
|
1109 |
pass
|
|
1110 |
opened_control = bzrdir.BzrDir.open(self.get_readonly_url('subdir')) |
|
1111 |
self.assertRaises(errors.NoRepositoryPresent, |
|
1112 |
opened_control.find_repository) |
|
1113 |