162
162
bzrdir.BzrDirFormat.set_default_format(old_format)
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)
164
177
def test_create_branch_and_repo_uses_default(self):
165
178
format = SampleBzrDirFormat()
166
179
old_format = bzrdir.BzrDirFormat.get_default_format()
213
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)
216
332
class ChrootedTests(TestCaseWithTransport):
217
333
"""A support class that provides readonly urls outside the local namespace.