158
162
bzrdir.BzrDirFormat.set_default_format(old_format)
160
def test_create_branch_and_repo(self):
164
def test_create_repository_under_shared(self):
165
# an explicit create_repository always does so.
166
# we trust the format is right from the 'create_repository test'
167
old_format = bzrdir.BzrDirFormat.get_default_format()
168
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
170
self.make_repository('.', shared=True)
171
repo = bzrdir.BzrDir.create_repository(self.get_url('child'))
172
self.assertTrue(isinstance(repo, repository.Repository))
173
self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/'))
175
bzrdir.BzrDirFormat.set_default_format(old_format)
177
def test_create_branch_and_repo_uses_default(self):
161
178
format = SampleBzrDirFormat()
162
179
old_format = bzrdir.BzrDirFormat.get_default_format()
163
180
bzrdir.BzrDirFormat.set_default_format(format)
168
185
bzrdir.BzrDirFormat.set_default_format(old_format)
187
def test_create_branch_and_repo_under_shared(self):
188
# creating a branch and repo in a shared repo uses the
190
old_format = bzrdir.BzrDirFormat.get_default_format()
191
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
193
self.make_repository('.', shared=True)
194
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'))
195
self.assertRaises(errors.NoRepositoryPresent,
196
branch.bzrdir.open_repository)
198
bzrdir.BzrDirFormat.set_default_format(old_format)
200
def test_create_branch_and_repo_under_shared_force_new(self):
201
# creating a branch and repo in a shared repo can be forced to
203
old_format = bzrdir.BzrDirFormat.get_default_format()
204
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
206
self.make_repository('.', shared=True)
207
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
209
branch.bzrdir.open_repository()
211
bzrdir.BzrDirFormat.set_default_format(old_format)
170
213
def test_create_standalone_working_tree(self):
171
214
format = SampleBzrDirFormat()
172
215
old_format = bzrdir.BzrDirFormat.get_default_format()
183
226
bzrdir.BzrDirFormat.set_default_format(old_format)
228
def test_create_standalone_working_tree_under_shared_repo(self):
229
# create standalone working tree always makes a repo.
230
old_format = bzrdir.BzrDirFormat.get_default_format()
231
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
233
self.make_repository('.', shared=True)
234
# note this is deliberately readonly, as this failure should
235
# occur before any writes.
236
self.assertRaises(errors.NotLocalUrl,
237
bzrdir.BzrDir.create_standalone_workingtree,
238
self.get_readonly_url('child'))
239
tree = bzrdir.BzrDir.create_standalone_workingtree('child')
240
tree.bzrdir.open_repository()
242
bzrdir.BzrDirFormat.set_default_format(old_format)
244
def test_create_branch_convenience(self):
245
# outside a repo the default conveniencec output is a repo+branch_tree
246
old_format = bzrdir.BzrDirFormat.get_default_format()
247
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
249
branch = bzrdir.BzrDir.create_branch_convenience('.')
250
branch.bzrdir.open_workingtree()
251
branch.bzrdir.open_repository()
253
bzrdir.BzrDirFormat.set_default_format(old_format)
255
def test_create_branch_convenience_under_shared_repo(self):
256
# inside a repo the default convenience output is a branch+ follow the
258
old_format = bzrdir.BzrDirFormat.get_default_format()
259
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
261
self.make_repository('.', shared=True)
262
branch = bzrdir.BzrDir.create_branch_convenience('child')
263
branch.bzrdir.open_workingtree()
264
self.assertRaises(errors.NoRepositoryPresent,
265
branch.bzrdir.open_repository)
267
bzrdir.BzrDirFormat.set_default_format(old_format)
269
def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
270
# inside a repo the default convenience output is a branch+ follow the
271
# repo tree policy but we can override that
272
old_format = bzrdir.BzrDirFormat.get_default_format()
273
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
275
self.make_repository('.', shared=True)
276
branch = bzrdir.BzrDir.create_branch_convenience('child',
277
force_new_tree=False)
278
self.assertRaises(errors.NoWorkingTree,
279
branch.bzrdir.open_workingtree)
280
self.assertRaises(errors.NoRepositoryPresent,
281
branch.bzrdir.open_repository)
283
bzrdir.BzrDirFormat.set_default_format(old_format)
285
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
286
# inside a repo the default convenience output is a branch+ follow the
288
old_format = bzrdir.BzrDirFormat.get_default_format()
289
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
291
repo = self.make_repository('.', shared=True)
292
repo.set_make_working_trees(False)
293
branch = bzrdir.BzrDir.create_branch_convenience('child')
294
self.assertRaises(errors.NoWorkingTree,
295
branch.bzrdir.open_workingtree)
296
self.assertRaises(errors.NoRepositoryPresent,
297
branch.bzrdir.open_repository)
299
bzrdir.BzrDirFormat.set_default_format(old_format)
301
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self):
302
# inside a repo the default convenience output is a branch+ follow the
303
# repo tree policy but we can override that
304
old_format = bzrdir.BzrDirFormat.get_default_format()
305
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
307
repo = self.make_repository('.', shared=True)
308
repo.set_make_working_trees(False)
309
branch = bzrdir.BzrDir.create_branch_convenience('child',
311
branch.bzrdir.open_workingtree()
312
self.assertRaises(errors.NoRepositoryPresent,
313
branch.bzrdir.open_repository)
315
bzrdir.BzrDirFormat.set_default_format(old_format)
317
def test_create_branch_convenience_under_shared_repo_force_new_repo(self):
318
# inside a repo the default convenience output is overridable to give
320
old_format = bzrdir.BzrDirFormat.get_default_format()
321
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
323
self.make_repository('.', shared=True)
324
branch = bzrdir.BzrDir.create_branch_convenience('child',
326
branch.bzrdir.open_repository()
327
branch.bzrdir.open_workingtree()
329
bzrdir.BzrDirFormat.set_default_format(old_format)
186
332
class ChrootedTests(TestCaseWithTransport):
187
333
"""A support class that provides readonly urls outside the local namespace.
207
353
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q'))
208
354
self.assertEqual('g/p/q', relpath)
356
def test_open_containing_transport(self):
357
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_transport,
358
get_transport(self.get_readonly_url('')))
359
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_transport,
360
get_transport(self.get_readonly_url('g/p/q')))
361
control = bzrdir.BzrDir.create(self.get_url())
362
branch, relpath = bzrdir.BzrDir.open_containing_transport(
363
get_transport(self.get_readonly_url('')))
364
self.assertEqual('', relpath)
365
branch, relpath = bzrdir.BzrDir.open_containing_transport(
366
get_transport(self.get_readonly_url('g/p/q')))
367
self.assertEqual('g/p/q', relpath)
211
370
class TestMeta1DirFormat(TestCaseWithTransport):
212
371
"""Tests specific to the meta1 dir format."""