~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-15 15:50:31 UTC
  • mto: This revision was merged to the branch mainline in revision 1927.
  • Revision ID: john@arbash-meinel.com-20060815155031-f1480d692d2cf9d2
There is no strict ordering file addition, other than directories are added before child files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005 Canonical Ltd
2
 
 
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
 
2
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
21
 
22
22
from StringIO import StringIO
23
23
 
24
 
import bzrlib.branch as branch
 
24
import bzrlib.branch
25
25
import bzrlib.bzrdir as bzrdir
26
26
import bzrlib.errors as errors
27
27
from bzrlib.errors import (NotBranchError,
41
41
    def test_get_set_default_format(self):
42
42
        old_format = bzrdir.BzrDirFormat.get_default_format()
43
43
        # default is BzrDirFormat6
44
 
        self.failUnless(isinstance(old_format, bzrdir.BzrDirFormat6))
 
44
        self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1))
45
45
        bzrdir.BzrDirFormat.set_default_format(SampleBzrDirFormat())
46
46
        # creating a bzr dir should now create an instrumented dir.
47
47
        try:
48
 
            result = bzrdir.BzrDir.create('memory:/')
 
48
            result = bzrdir.BzrDir.create('memory:///')
49
49
            self.failUnless(isinstance(result, SampleBzrDir))
50
50
        finally:
51
51
            bzrdir.BzrDirFormat.set_default_format(old_format)
52
52
        self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format())
53
53
 
54
54
 
55
 
class SampleBranch(branch.Branch):
 
55
class SampleBranch(bzrlib.branch.Branch):
56
56
    """A dummy branch for guess what, dummy use."""
57
57
 
58
58
    def __init__(self, dir):
62
62
class SampleBzrDir(bzrdir.BzrDir):
63
63
    """A sample BzrDir implementation to allow testing static methods."""
64
64
 
65
 
    def create_repository(self):
 
65
    def create_repository(self, shared=False):
66
66
        """See BzrDir.create_repository."""
67
67
        return "A repository"
68
68
 
 
69
    def open_repository(self):
 
70
        """See BzrDir.open_repository."""
 
71
        return "A repository"
 
72
 
69
73
    def create_branch(self):
70
74
        """See BzrDir.create_branch."""
71
75
        return SampleBranch(self)
139
143
        bzrdir.BzrDirFormat.register_format(format)
140
144
        # which bzrdir.Open will refuse (not supported)
141
145
        self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url)
 
146
        # which bzrdir.open_containing will refuse (not supported)
 
147
        self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url)
142
148
        # but open_downlevel will work
143
149
        t = get_transport(url)
144
150
        self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url))
157
163
        finally:
158
164
            bzrdir.BzrDirFormat.set_default_format(old_format)
159
165
 
160
 
    def test_create_branch_and_repo(self):
 
166
    def test_create_repository_shared(self):
 
167
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
168
        repo = bzrdir.BzrDir.create_repository('.', shared=True)
 
169
        self.assertTrue(repo.is_shared())
 
170
 
 
171
    def test_create_repository_nonshared(self):
 
172
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
173
        repo = bzrdir.BzrDir.create_repository('.')
 
174
        self.assertFalse(repo.is_shared())
 
175
 
 
176
    def test_create_repository_under_shared(self):
 
177
        # an explicit create_repository always does so.
 
178
        # we trust the format is right from the 'create_repository test'
 
179
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
180
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
181
        try:
 
182
            self.make_repository('.', shared=True)
 
183
            repo = bzrdir.BzrDir.create_repository(self.get_url('child'))
 
184
            self.assertTrue(isinstance(repo, repository.Repository))
 
185
            self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/'))
 
186
        finally:
 
187
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
188
 
 
189
    def test_create_branch_and_repo_uses_default(self):
161
190
        format = SampleBzrDirFormat()
162
191
        old_format = bzrdir.BzrDirFormat.get_default_format()
163
192
        bzrdir.BzrDirFormat.set_default_format(format)
167
196
        finally:
168
197
            bzrdir.BzrDirFormat.set_default_format(old_format)
169
198
 
 
199
    def test_create_branch_and_repo_under_shared(self):
 
200
        # creating a branch and repo in a shared repo uses the
 
201
        # shared repository
 
202
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
203
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
204
        try:
 
205
            self.make_repository('.', shared=True)
 
206
            branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'))
 
207
            self.assertRaises(errors.NoRepositoryPresent,
 
208
                              branch.bzrdir.open_repository)
 
209
        finally:
 
210
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
211
 
 
212
    def test_create_branch_and_repo_under_shared_force_new(self):
 
213
        # creating a branch and repo in a shared repo can be forced to 
 
214
        # make a new repo
 
215
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
216
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
217
        try:
 
218
            self.make_repository('.', shared=True)
 
219
            branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
 
220
                                                          force_new_repo=True)
 
221
            branch.bzrdir.open_repository()
 
222
        finally:
 
223
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
224
 
170
225
    def test_create_standalone_working_tree(self):
171
226
        format = SampleBzrDirFormat()
172
227
        old_format = bzrdir.BzrDirFormat.get_default_format()
182
237
        finally:
183
238
            bzrdir.BzrDirFormat.set_default_format(old_format)
184
239
 
 
240
    def test_create_standalone_working_tree_under_shared_repo(self):
 
241
        # create standalone working tree always makes a repo.
 
242
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
243
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
244
        try:
 
245
            self.make_repository('.', shared=True)
 
246
            # note this is deliberately readonly, as this failure should 
 
247
            # occur before any writes.
 
248
            self.assertRaises(errors.NotLocalUrl,
 
249
                              bzrdir.BzrDir.create_standalone_workingtree,
 
250
                              self.get_readonly_url('child'))
 
251
            tree = bzrdir.BzrDir.create_standalone_workingtree('child')
 
252
            tree.bzrdir.open_repository()
 
253
        finally:
 
254
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
255
 
 
256
    def test_create_branch_convenience(self):
 
257
        # outside a repo the default convenience output is a repo+branch_tree
 
258
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
259
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
260
        try:
 
261
            branch = bzrdir.BzrDir.create_branch_convenience('.')
 
262
            branch.bzrdir.open_workingtree()
 
263
            branch.bzrdir.open_repository()
 
264
        finally:
 
265
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
266
 
 
267
    def test_create_branch_convenience_root(self):
 
268
        """Creating a branch at the root of a fs should work."""
 
269
        self.transport_server = MemoryServer
 
270
        # outside a repo the default convenience output is a repo+branch_tree
 
271
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
272
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
273
        try:
 
274
            branch = bzrdir.BzrDir.create_branch_convenience(self.get_url())
 
275
            self.assertRaises(errors.NoWorkingTree,
 
276
                              branch.bzrdir.open_workingtree)
 
277
            branch.bzrdir.open_repository()
 
278
        finally:
 
279
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
280
 
 
281
    def test_create_branch_convenience_under_shared_repo(self):
 
282
        # inside a repo the default convenience output is a branch+ follow the
 
283
        # repo tree policy
 
284
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
285
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
286
        try:
 
287
            self.make_repository('.', shared=True)
 
288
            branch = bzrdir.BzrDir.create_branch_convenience('child')
 
289
            branch.bzrdir.open_workingtree()
 
290
            self.assertRaises(errors.NoRepositoryPresent,
 
291
                              branch.bzrdir.open_repository)
 
292
        finally:
 
293
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
294
            
 
295
    def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
 
296
        # inside a repo the default convenience output is a branch+ follow the
 
297
        # repo tree policy but we can override that
 
298
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
299
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
300
        try:
 
301
            self.make_repository('.', shared=True)
 
302
            branch = bzrdir.BzrDir.create_branch_convenience('child',
 
303
                force_new_tree=False)
 
304
            self.assertRaises(errors.NoWorkingTree,
 
305
                              branch.bzrdir.open_workingtree)
 
306
            self.assertRaises(errors.NoRepositoryPresent,
 
307
                              branch.bzrdir.open_repository)
 
308
        finally:
 
309
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
310
            
 
311
    def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
 
312
        # inside a repo the default convenience output is a branch+ follow the
 
313
        # repo tree policy
 
314
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
315
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
316
        try:
 
317
            repo = self.make_repository('.', shared=True)
 
318
            repo.set_make_working_trees(False)
 
319
            branch = bzrdir.BzrDir.create_branch_convenience('child')
 
320
            self.assertRaises(errors.NoWorkingTree,
 
321
                              branch.bzrdir.open_workingtree)
 
322
            self.assertRaises(errors.NoRepositoryPresent,
 
323
                              branch.bzrdir.open_repository)
 
324
        finally:
 
325
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
326
 
 
327
    def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self):
 
328
        # inside a repo the default convenience output is a branch+ follow the
 
329
        # repo tree policy but we can override that
 
330
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
331
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
332
        try:
 
333
            repo = self.make_repository('.', shared=True)
 
334
            repo.set_make_working_trees(False)
 
335
            branch = bzrdir.BzrDir.create_branch_convenience('child',
 
336
                force_new_tree=True)
 
337
            branch.bzrdir.open_workingtree()
 
338
            self.assertRaises(errors.NoRepositoryPresent,
 
339
                              branch.bzrdir.open_repository)
 
340
        finally:
 
341
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
342
 
 
343
    def test_create_branch_convenience_under_shared_repo_force_new_repo(self):
 
344
        # inside a repo the default convenience output is overridable to give
 
345
        # repo+branch+tree
 
346
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
347
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
348
        try:
 
349
            self.make_repository('.', shared=True)
 
350
            branch = bzrdir.BzrDir.create_branch_convenience('child',
 
351
                force_new_repo=True)
 
352
            branch.bzrdir.open_repository()
 
353
            branch.bzrdir.open_workingtree()
 
354
        finally:
 
355
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
356
 
185
357
 
186
358
class ChrootedTests(TestCaseWithTransport):
187
359
    """A support class that provides readonly urls outside the local namespace.
207
379
        branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q'))
208
380
        self.assertEqual('g/p/q', relpath)
209
381
 
 
382
    def test_open_containing_from_transport(self):
 
383
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,
 
384
                          get_transport(self.get_readonly_url('')))
 
385
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,
 
386
                          get_transport(self.get_readonly_url('g/p/q')))
 
387
        control = bzrdir.BzrDir.create(self.get_url())
 
388
        branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
 
389
            get_transport(self.get_readonly_url('')))
 
390
        self.assertEqual('', relpath)
 
391
        branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
 
392
            get_transport(self.get_readonly_url('g/p/q')))
 
393
        self.assertEqual('g/p/q', relpath)
 
394
 
210
395
 
211
396
class TestMeta1DirFormat(TestCaseWithTransport):
212
397
    """Tests specific to the meta1 dir format."""
217
402
        branch_base = t.clone('branch').base
218
403
        self.assertEqual(branch_base, dir.get_branch_transport(None).base)
219
404
        self.assertEqual(branch_base,
220
 
                         dir.get_branch_transport(branch.BzrBranchFormat5()).base)
 
405
                         dir.get_branch_transport(bzrlib.branch.BzrBranchFormat5()).base)
221
406
        repository_base = t.clone('repository').base
222
407
        self.assertEqual(repository_base, dir.get_repository_transport(None).base)
223
408
        self.assertEqual(repository_base,
226
411
        self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base)
227
412
        self.assertEqual(checkout_base,
228
413
                         dir.get_workingtree_transport(workingtree.WorkingTreeFormat3()).base)
 
414
 
 
415
    def test_meta1dir_uses_lockdir(self):
 
416
        """Meta1 format uses a LockDir to guard the whole directory, not a file."""
 
417
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
418
        t = dir.transport
 
419
        self.assertIsDirectory('branch-lock', t)
 
420
 
 
421
        
 
422
class TestFormat5(TestCaseWithTransport):
 
423
    """Tests specific to the version 5 bzrdir format."""
 
424
 
 
425
    def test_same_lockfiles_between_tree_repo_branch(self):
 
426
        # this checks that only a single lockfiles instance is created 
 
427
        # for format 5 objects
 
428
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
 
429
        def check_dir_components_use_same_lock(dir):
 
430
            ctrl_1 = dir.open_repository().control_files
 
431
            ctrl_2 = dir.open_branch().control_files
 
432
            ctrl_3 = dir.open_workingtree()._control_files
 
433
            self.assertTrue(ctrl_1 is ctrl_2)
 
434
            self.assertTrue(ctrl_2 is ctrl_3)
 
435
        check_dir_components_use_same_lock(dir)
 
436
        # and if we open it normally.
 
437
        dir = bzrdir.BzrDir.open(self.get_url())
 
438
        check_dir_components_use_same_lock(dir)
 
439
    
 
440
    def test_can_convert(self):
 
441
        # format 5 dirs are convertable
 
442
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
 
443
        self.assertTrue(dir.can_convert_format())
 
444
    
 
445
    def test_needs_conversion(self):
 
446
        # format 5 dirs need a conversion if they are not the default.
 
447
        # and they start of not the default.
 
448
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
449
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirFormat5())
 
450
        try:
 
451
            dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
 
452
            self.assertFalse(dir.needs_format_conversion())
 
453
        finally:
 
454
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
455
        self.assertTrue(dir.needs_format_conversion())
 
456
 
 
457
 
 
458
class TestFormat6(TestCaseWithTransport):
 
459
    """Tests specific to the version 6 bzrdir format."""
 
460
 
 
461
    def test_same_lockfiles_between_tree_repo_branch(self):
 
462
        # this checks that only a single lockfiles instance is created 
 
463
        # for format 6 objects
 
464
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
 
465
        def check_dir_components_use_same_lock(dir):
 
466
            ctrl_1 = dir.open_repository().control_files
 
467
            ctrl_2 = dir.open_branch().control_files
 
468
            ctrl_3 = dir.open_workingtree()._control_files
 
469
            self.assertTrue(ctrl_1 is ctrl_2)
 
470
            self.assertTrue(ctrl_2 is ctrl_3)
 
471
        check_dir_components_use_same_lock(dir)
 
472
        # and if we open it normally.
 
473
        dir = bzrdir.BzrDir.open(self.get_url())
 
474
        check_dir_components_use_same_lock(dir)
 
475
    
 
476
    def test_can_convert(self):
 
477
        # format 6 dirs are convertable
 
478
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
 
479
        self.assertTrue(dir.can_convert_format())
 
480
    
 
481
    def test_needs_conversion(self):
 
482
        # format 6 dirs need an conversion if they are not the default.
 
483
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
484
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
485
        try:
 
486
            dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
 
487
            self.assertTrue(dir.needs_format_conversion())
 
488
        finally:
 
489
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
490
 
 
491
 
 
492
class NotBzrDir(bzrlib.bzrdir.BzrDir):
 
493
    """A non .bzr based control directory."""
 
494
 
 
495
    def __init__(self, transport, format):
 
496
        self._format = format
 
497
        self.root_transport = transport
 
498
        self.transport = transport.clone('.not')
 
499
 
 
500
 
 
501
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat):
 
502
    """A test class representing any non-.bzr based disk format."""
 
503
 
 
504
    def initialize_on_transport(self, transport):
 
505
        """Initialize a new .not dir in the base directory of a Transport."""
 
506
        transport.mkdir('.not')
 
507
        return self.open(transport)
 
508
 
 
509
    def open(self, transport):
 
510
        """Open this directory."""
 
511
        return NotBzrDir(transport, self)
 
512
 
 
513
    @classmethod
 
514
    def _known_formats(self):
 
515
        return set([NotBzrDirFormat()])
 
516
 
 
517
    @classmethod
 
518
    def probe_transport(self, transport):
 
519
        """Our format is present if the transport ends in '.not/'."""
 
520
        if transport.has('.not'):
 
521
            return NotBzrDirFormat()
 
522
 
 
523
 
 
524
class TestNotBzrDir(TestCaseWithTransport):
 
525
    """Tests for using the bzrdir api with a non .bzr based disk format.
 
526
    
 
527
    If/when one of these is in the core, we can let the implementation tests
 
528
    verify this works.
 
529
    """
 
530
 
 
531
    def test_create_and_find_format(self):
 
532
        # create a .notbzr dir 
 
533
        format = NotBzrDirFormat()
 
534
        dir = format.initialize(self.get_url())
 
535
        self.assertIsInstance(dir, NotBzrDir)
 
536
        # now probe for it.
 
537
        bzrlib.bzrdir.BzrDirFormat.register_control_format(format)
 
538
        try:
 
539
            found = bzrlib.bzrdir.BzrDirFormat.find_format(
 
540
                get_transport(self.get_url()))
 
541
            self.assertIsInstance(found, NotBzrDirFormat)
 
542
        finally:
 
543
            bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format)
 
544
 
 
545
    def test_included_in_known_formats(self):
 
546
        bzrlib.bzrdir.BzrDirFormat.register_control_format(NotBzrDirFormat)
 
547
        try:
 
548
            formats = bzrlib.bzrdir.BzrDirFormat.known_formats()
 
549
            for format in formats:
 
550
                if isinstance(format, NotBzrDirFormat):
 
551
                    return
 
552
            self.fail("No NotBzrDirFormat in %s" % formats)
 
553
        finally:
 
554
            bzrlib.bzrdir.BzrDirFormat.unregister_control_format(NotBzrDirFormat)
 
555
 
 
556
 
 
557
class NonLocalTests(TestCaseWithTransport):
 
558
    """Tests for bzrdir static behaviour on non local paths."""
 
559
 
 
560
    def setUp(self):
 
561
        super(NonLocalTests, self).setUp()
 
562
        self.transport_server = MemoryServer
 
563
    
 
564
    def test_create_branch_convenience(self):
 
565
        # outside a repo the default convenience output is a repo+branch_tree
 
566
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
567
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
568
        try:
 
569
            branch = bzrdir.BzrDir.create_branch_convenience(self.get_url('foo'))
 
570
            self.assertRaises(errors.NoWorkingTree,
 
571
                              branch.bzrdir.open_workingtree)
 
572
            branch.bzrdir.open_repository()
 
573
        finally:
 
574
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
575
 
 
576
    def test_create_branch_convenience_force_tree_not_local_fails(self):
 
577
        # outside a repo the default convenience output is a repo+branch_tree
 
578
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
579
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
580
        try:
 
581
            self.assertRaises(errors.NotLocalUrl,
 
582
                bzrdir.BzrDir.create_branch_convenience,
 
583
                self.get_url('foo'),
 
584
                force_new_tree=True)
 
585
            t = get_transport(self.get_url('.'))
 
586
            self.assertFalse(t.has('foo'))
 
587
        finally:
 
588
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
589
 
 
590
    def test_clone(self):
 
591
        # clone into a nonlocal path works
 
592
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
593
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
594
        try:
 
595
            branch = bzrdir.BzrDir.create_branch_convenience('local')
 
596
        finally:
 
597
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
598
        branch.bzrdir.open_workingtree()
 
599
        result = branch.bzrdir.clone(self.get_url('remote'))
 
600
        self.assertRaises(errors.NoWorkingTree,
 
601
                          result.open_workingtree)
 
602
        result.open_branch()
 
603
        result.open_repository()
 
604