~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Robert Collins
  • Date: 2006-02-15 03:58:15 UTC
  • mto: (1534.5.2 bzr-dir)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060215035815-93475eacfb0b41d2
Finish use of repositories support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
        finally:
162
162
            bzrdir.BzrDirFormat.set_default_format(old_format)
163
163
 
 
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())
 
169
        try:
 
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/'))
 
174
        finally:
 
175
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
176
 
164
177
    def test_create_branch_and_repo_uses_default(self):
165
178
        format = SampleBzrDirFormat()
166
179
        old_format = bzrdir.BzrDirFormat.get_default_format()
212
225
        finally:
213
226
            bzrdir.BzrDirFormat.set_default_format(old_format)
214
227
 
 
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())
 
232
        try:
 
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()
 
241
        finally:
 
242
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
243
 
 
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())
 
248
        try:
 
249
            branch = bzrdir.BzrDir.create_branch_convenience('.')
 
250
            branch.bzrdir.open_workingtree()
 
251
            branch.bzrdir.open_repository()
 
252
        finally:
 
253
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
254
 
 
255
    def test_create_branch_convenience_under_shared_repo(self):
 
256
        # inside a repo the default convenience output is a branch+ follow the
 
257
        # repo tree policy
 
258
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
259
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
260
        try:
 
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)
 
266
        finally:
 
267
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
268
            
 
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())
 
274
        try:
 
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)
 
282
        finally:
 
283
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
284
            
 
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
 
287
        # repo tree policy
 
288
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
289
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
290
        try:
 
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)
 
298
        finally:
 
299
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
300
 
 
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())
 
306
        try:
 
307
            repo = self.make_repository('.', shared=True)
 
308
            repo.set_make_working_trees(False)
 
309
            branch = bzrdir.BzrDir.create_branch_convenience('child',
 
310
                force_new_tree=True)
 
311
            branch.bzrdir.open_workingtree()
 
312
            self.assertRaises(errors.NoRepositoryPresent,
 
313
                              branch.bzrdir.open_repository)
 
314
        finally:
 
315
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
316
 
 
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
 
319
        # repo+branch+tree
 
320
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
321
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
322
        try:
 
323
            self.make_repository('.', shared=True)
 
324
            branch = bzrdir.BzrDir.create_branch_convenience('child',
 
325
                force_new_repo=True)
 
326
            branch.bzrdir.open_repository()
 
327
            branch.bzrdir.open_workingtree()
 
328
        finally:
 
329
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
330
 
215
331
 
216
332
class ChrootedTests(TestCaseWithTransport):
217
333
    """A support class that provides readonly urls outside the local namespace.