1
# Copyright (C) 2005, 2006 Canonical Ltd
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.
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.
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
17
"""Tests for the BzrDir facility and any format specific tests.
19
For interface contract tests, see tests/bzr_dir_implementations.
22
from StringIO import StringIO
29
import bzrlib.bzrdir as bzrdir
30
import bzrlib.errors as errors
31
from bzrlib.errors import (NotBranchError,
33
UnsupportedFormatError,
35
import bzrlib.repository as repository
36
from bzrlib.tests import TestCase, TestCaseWithTransport
37
from bzrlib.tests.HttpServer import HttpServer
38
from bzrlib.transport import get_transport
39
from bzrlib.transport.memory import MemoryServer
40
import bzrlib.workingtree as workingtree
43
class TestDefaultFormat(TestCase):
45
def test_get_set_default_format(self):
46
old_format = bzrdir.BzrDirFormat.get_default_format()
47
# default is BzrDirFormat6
48
self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1))
49
self.applyDeprecated(symbol_versioning.zero_fourteen,
50
bzrdir.BzrDirFormat.set_default_format,
52
# creating a bzr dir should now create an instrumented dir.
54
result = bzrdir.BzrDir.create('memory:///')
55
self.failUnless(isinstance(result, SampleBzrDir))
57
self.applyDeprecated(symbol_versioning.zero_fourteen,
58
bzrdir.BzrDirFormat.set_default_format, old_format)
59
self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format())
62
class TestFormatRegistry(TestCase):
64
def make_format_registry(self):
65
my_format_registry = bzrdir.BzrDirFormatRegistry()
66
my_format_registry.register('weave', bzrdir.BzrDirFormat6,
67
'Pre-0.8 format. Slower and does not support checkouts or shared'
68
' repositories', deprecated=True)
69
my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
70
'BzrDirFormat6', 'Format registered lazily', deprecated=True)
71
my_format_registry.register_metadir('knit', 'RepositoryFormatKnit1',
73
my_format_registry.set_default('knit')
74
my_format_registry.register_metadir('metaweave', 'RepositoryFormat7',
75
'Transitional format in 0.8. Slower than knit.', deprecated=True)
76
my_format_registry.register_metadir('experimental-knit2',
77
'RepositoryFormatKnit2',
78
'Experimental successor to knit. Use at your own risk.')
79
return my_format_registry
81
def test_format_registry(self):
82
my_format_registry = self.make_format_registry()
83
my_bzrdir = my_format_registry.make_bzrdir('lazy')
84
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
85
my_bzrdir = my_format_registry.make_bzrdir('weave')
86
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
87
my_bzrdir = my_format_registry.make_bzrdir('default')
88
self.assertIsInstance(my_bzrdir.repository_format,
89
repository.RepositoryFormatKnit1)
90
my_bzrdir = my_format_registry.make_bzrdir('knit')
91
self.assertIsInstance(my_bzrdir.repository_format,
92
repository.RepositoryFormatKnit1)
93
my_bzrdir = my_format_registry.make_bzrdir('metaweave')
94
self.assertIsInstance(my_bzrdir.repository_format,
95
repository.RepositoryFormat7)
97
def test_get_help(self):
98
my_format_registry = self.make_format_registry()
99
self.assertEqual('Format registered lazily',
100
my_format_registry.get_help('lazy'))
101
self.assertEqual('Format using knits',
102
my_format_registry.get_help('knit'))
103
self.assertEqual('Format using knits',
104
my_format_registry.get_help('default'))
105
self.assertEqual('Pre-0.8 format. Slower and does not support'
106
' checkouts or shared repositories',
107
my_format_registry.get_help('weave'))
109
def test_help_topic(self):
110
topics = help_topics.HelpTopicRegistry()
111
topics.register('formats', self.make_format_registry().help_topic,
113
topic = topics.get_detail('formats')
114
new, deprecated = topic.split('Deprecated formats')
115
self.assertContainsRe(new, 'Bazaar directory formats')
116
self.assertContainsRe(new,
117
' knit/default:\n \(native\) Format using knits\n')
118
self.assertContainsRe(deprecated,
119
' lazy:\n \(native\) Format registered lazily\n')
121
def test_set_default_repository(self):
122
default_factory = bzrdir.format_registry.get('default')
123
old_default = [k for k, v in bzrdir.format_registry.iteritems()
124
if v == default_factory and k != 'default'][0]
125
bzrdir.format_registry.set_default_repository('metaweave')
127
self.assertIs(bzrdir.format_registry.get('metaweave'),
128
bzrdir.format_registry.get('default'))
130
repository.RepositoryFormat.get_default_format().__class__,
131
repository.RepositoryFormat7)
133
bzrdir.format_registry.set_default_repository(old_default)
135
class SampleBranch(bzrlib.branch.Branch):
136
"""A dummy branch for guess what, dummy use."""
138
def __init__(self, dir):
142
class SampleBzrDir(bzrdir.BzrDir):
143
"""A sample BzrDir implementation to allow testing static methods."""
145
def create_repository(self, shared=False):
146
"""See BzrDir.create_repository."""
147
return "A repository"
149
def open_repository(self):
150
"""See BzrDir.open_repository."""
151
return "A repository"
153
def create_branch(self):
154
"""See BzrDir.create_branch."""
155
return SampleBranch(self)
157
def create_workingtree(self):
158
"""See BzrDir.create_workingtree."""
162
class SampleBzrDirFormat(bzrdir.BzrDirFormat):
165
this format is initializable, unsupported to aid in testing the
166
open and open_downlevel routines.
169
def get_format_string(self):
170
"""See BzrDirFormat.get_format_string()."""
171
return "Sample .bzr dir format."
173
def initialize(self, url):
174
"""Create a bzr dir."""
175
t = get_transport(url)
177
t.put_bytes('.bzr/branch-format', self.get_format_string())
178
return SampleBzrDir(t, self)
180
def is_supported(self):
183
def open(self, transport, _found=None):
184
return "opened branch."
187
class TestBzrDirFormat(TestCaseWithTransport):
188
"""Tests for the BzrDirFormat facility."""
190
def test_find_format(self):
191
# is the right format object found for a branch?
192
# create a branch with a few known format objects.
193
# this is not quite the same as
194
t = get_transport(self.get_url())
195
self.build_tree(["foo/", "bar/"], transport=t)
196
def check_format(format, url):
197
format.initialize(url)
198
t = get_transport(url)
199
found_format = bzrdir.BzrDirFormat.find_format(t)
200
self.failUnless(isinstance(found_format, format.__class__))
201
check_format(bzrdir.BzrDirFormat5(), "foo")
202
check_format(bzrdir.BzrDirFormat6(), "bar")
204
def test_find_format_nothing_there(self):
205
self.assertRaises(NotBranchError,
206
bzrdir.BzrDirFormat.find_format,
209
def test_find_format_unknown_format(self):
210
t = get_transport(self.get_url())
212
t.put_bytes('.bzr/branch-format', '')
213
self.assertRaises(UnknownFormatError,
214
bzrdir.BzrDirFormat.find_format,
217
def test_register_unregister_format(self):
218
format = SampleBzrDirFormat()
221
format.initialize(url)
222
# register a format for it.
223
bzrdir.BzrDirFormat.register_format(format)
224
# which bzrdir.Open will refuse (not supported)
225
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url)
226
# which bzrdir.open_containing will refuse (not supported)
227
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url)
228
# but open_downlevel will work
229
t = get_transport(url)
230
self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url))
231
# unregister the format
232
bzrdir.BzrDirFormat.unregister_format(format)
233
# now open_downlevel should fail too.
234
self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url)
236
def test_create_repository(self):
237
format = SampleBzrDirFormat()
238
repo = bzrdir.BzrDir.create_repository(self.get_url(), format=format)
239
self.assertEqual('A repository', repo)
241
def test_create_repository_shared(self):
242
old_format = bzrdir.BzrDirFormat.get_default_format()
243
repo = bzrdir.BzrDir.create_repository('.', shared=True)
244
self.assertTrue(repo.is_shared())
246
def test_create_repository_nonshared(self):
247
old_format = bzrdir.BzrDirFormat.get_default_format()
248
repo = bzrdir.BzrDir.create_repository('.')
249
self.assertFalse(repo.is_shared())
251
def test_create_repository_under_shared(self):
252
# an explicit create_repository always does so.
253
# we trust the format is right from the 'create_repository test'
254
format = bzrdir.format_registry.make_bzrdir('knit')
255
self.make_repository('.', shared=True, format=format)
256
repo = bzrdir.BzrDir.create_repository(self.get_url('child'),
258
self.assertTrue(isinstance(repo, repository.Repository))
259
self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/'))
261
def test_create_branch_and_repo_uses_default(self):
262
format = SampleBzrDirFormat()
263
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url(),
265
self.assertTrue(isinstance(branch, SampleBranch))
267
def test_create_branch_and_repo_under_shared(self):
268
# creating a branch and repo in a shared repo uses the
270
format = bzrdir.format_registry.make_bzrdir('knit')
271
self.make_repository('.', shared=True, format=format)
272
branch = bzrdir.BzrDir.create_branch_and_repo(
273
self.get_url('child'), format=format)
274
self.assertRaises(errors.NoRepositoryPresent,
275
branch.bzrdir.open_repository)
277
def test_create_branch_and_repo_under_shared_force_new(self):
278
# creating a branch and repo in a shared repo can be forced to
280
format = bzrdir.format_registry.make_bzrdir('knit')
281
self.make_repository('.', shared=True, format=format)
282
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
285
branch.bzrdir.open_repository()
287
def test_create_standalone_working_tree(self):
288
format = SampleBzrDirFormat()
289
# note this is deliberately readonly, as this failure should
290
# occur before any writes.
291
self.assertRaises(errors.NotLocalUrl,
292
bzrdir.BzrDir.create_standalone_workingtree,
293
self.get_readonly_url(), format=format)
294
tree = bzrdir.BzrDir.create_standalone_workingtree('.',
296
self.assertEqual('A tree', tree)
298
def test_create_standalone_working_tree_under_shared_repo(self):
299
# create standalone working tree always makes a repo.
300
format = bzrdir.format_registry.make_bzrdir('knit')
301
self.make_repository('.', shared=True, format=format)
302
# note this is deliberately readonly, as this failure should
303
# occur before any writes.
304
self.assertRaises(errors.NotLocalUrl,
305
bzrdir.BzrDir.create_standalone_workingtree,
306
self.get_readonly_url('child'), format=format)
307
tree = bzrdir.BzrDir.create_standalone_workingtree('child',
309
tree.bzrdir.open_repository()
311
def test_create_branch_convenience(self):
312
# outside a repo the default convenience output is a repo+branch_tree
313
format = bzrdir.format_registry.make_bzrdir('knit')
314
branch = bzrdir.BzrDir.create_branch_convenience('.', format=format)
315
branch.bzrdir.open_workingtree()
316
branch.bzrdir.open_repository()
318
def test_create_branch_convenience_root(self):
319
"""Creating a branch at the root of a fs should work."""
320
self.transport_server = MemoryServer
321
# outside a repo the default convenience output is a repo+branch_tree
322
format = bzrdir.format_registry.make_bzrdir('knit')
323
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
325
self.assertRaises(errors.NoWorkingTree,
326
branch.bzrdir.open_workingtree)
327
branch.bzrdir.open_repository()
329
def test_create_branch_convenience_under_shared_repo(self):
330
# inside a repo the default convenience output is a branch+ follow the
332
format = bzrdir.format_registry.make_bzrdir('knit')
333
self.make_repository('.', shared=True, format=format)
334
branch = bzrdir.BzrDir.create_branch_convenience('child',
336
branch.bzrdir.open_workingtree()
337
self.assertRaises(errors.NoRepositoryPresent,
338
branch.bzrdir.open_repository)
340
def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
341
# inside a repo the default convenience output is a branch+ follow the
342
# repo tree policy but we can override that
343
format = bzrdir.format_registry.make_bzrdir('knit')
344
self.make_repository('.', shared=True, format=format)
345
branch = bzrdir.BzrDir.create_branch_convenience('child',
346
force_new_tree=False, format=format)
347
self.assertRaises(errors.NoWorkingTree,
348
branch.bzrdir.open_workingtree)
349
self.assertRaises(errors.NoRepositoryPresent,
350
branch.bzrdir.open_repository)
352
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
353
# inside a repo the default convenience output is a branch+ follow the
355
format = bzrdir.format_registry.make_bzrdir('knit')
356
repo = self.make_repository('.', shared=True, format=format)
357
repo.set_make_working_trees(False)
358
branch = bzrdir.BzrDir.create_branch_convenience('child',
360
self.assertRaises(errors.NoWorkingTree,
361
branch.bzrdir.open_workingtree)
362
self.assertRaises(errors.NoRepositoryPresent,
363
branch.bzrdir.open_repository)
365
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self):
366
# inside a repo the default convenience output is a branch+ follow the
367
# repo tree policy but we can override that
368
format = bzrdir.format_registry.make_bzrdir('knit')
369
repo = self.make_repository('.', shared=True, format=format)
370
repo.set_make_working_trees(False)
371
branch = bzrdir.BzrDir.create_branch_convenience('child',
372
force_new_tree=True, format=format)
373
branch.bzrdir.open_workingtree()
374
self.assertRaises(errors.NoRepositoryPresent,
375
branch.bzrdir.open_repository)
377
def test_create_branch_convenience_under_shared_repo_force_new_repo(self):
378
# inside a repo the default convenience output is overridable to give
380
format = bzrdir.format_registry.make_bzrdir('knit')
381
self.make_repository('.', shared=True, format=format)
382
branch = bzrdir.BzrDir.create_branch_convenience('child',
383
force_new_repo=True, format=format)
384
branch.bzrdir.open_repository()
385
branch.bzrdir.open_workingtree()
388
class ChrootedTests(TestCaseWithTransport):
389
"""A support class that provides readonly urls outside the local namespace.
391
This is done by checking if self.transport_server is a MemoryServer. if it
392
is then we are chrooted already, if it is not then an HttpServer is used
397
super(ChrootedTests, self).setUp()
398
if not self.transport_server == MemoryServer:
399
self.transport_readonly_server = HttpServer
401
def test_open_containing(self):
402
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing,
403
self.get_readonly_url(''))
404
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing,
405
self.get_readonly_url('g/p/q'))
406
control = bzrdir.BzrDir.create(self.get_url())
407
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url(''))
408
self.assertEqual('', relpath)
409
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q'))
410
self.assertEqual('g/p/q', relpath)
412
def test_open_containing_from_transport(self):
413
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,
414
get_transport(self.get_readonly_url('')))
415
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,
416
get_transport(self.get_readonly_url('g/p/q')))
417
control = bzrdir.BzrDir.create(self.get_url())
418
branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
419
get_transport(self.get_readonly_url('')))
420
self.assertEqual('', relpath)
421
branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
422
get_transport(self.get_readonly_url('g/p/q')))
423
self.assertEqual('g/p/q', relpath)
425
def test_open_from_transport(self):
426
# transport pointing at bzrdir should give a bzrdir with root transport
427
# set to the given transport
428
control = bzrdir.BzrDir.create(self.get_url())
429
transport = get_transport(self.get_url())
430
opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport)
431
self.assertEqual(transport.base, opened_bzrdir.root_transport.base)
432
self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir)
434
def test_open_from_transport_no_bzrdir(self):
435
transport = get_transport(self.get_url())
436
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
439
def test_open_from_transport_bzrdir_in_parent(self):
440
control = bzrdir.BzrDir.create(self.get_url())
441
transport = get_transport(self.get_url())
442
transport.mkdir('subdir')
443
transport = transport.clone('subdir')
444
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
448
class TestMeta1DirFormat(TestCaseWithTransport):
449
"""Tests specific to the meta1 dir format."""
451
def test_right_base_dirs(self):
452
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
454
branch_base = t.clone('branch').base
455
self.assertEqual(branch_base, dir.get_branch_transport(None).base)
456
self.assertEqual(branch_base,
457
dir.get_branch_transport(bzrlib.branch.BzrBranchFormat5()).base)
458
repository_base = t.clone('repository').base
459
self.assertEqual(repository_base, dir.get_repository_transport(None).base)
460
self.assertEqual(repository_base,
461
dir.get_repository_transport(repository.RepositoryFormat7()).base)
462
checkout_base = t.clone('checkout').base
463
self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base)
464
self.assertEqual(checkout_base,
465
dir.get_workingtree_transport(workingtree.WorkingTreeFormat3()).base)
467
def test_meta1dir_uses_lockdir(self):
468
"""Meta1 format uses a LockDir to guard the whole directory, not a file."""
469
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
471
self.assertIsDirectory('branch-lock', t)
474
class TestFormat5(TestCaseWithTransport):
475
"""Tests specific to the version 5 bzrdir format."""
477
def test_same_lockfiles_between_tree_repo_branch(self):
478
# this checks that only a single lockfiles instance is created
479
# for format 5 objects
480
dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
481
def check_dir_components_use_same_lock(dir):
482
ctrl_1 = dir.open_repository().control_files
483
ctrl_2 = dir.open_branch().control_files
484
ctrl_3 = dir.open_workingtree()._control_files
485
self.assertTrue(ctrl_1 is ctrl_2)
486
self.assertTrue(ctrl_2 is ctrl_3)
487
check_dir_components_use_same_lock(dir)
488
# and if we open it normally.
489
dir = bzrdir.BzrDir.open(self.get_url())
490
check_dir_components_use_same_lock(dir)
492
def test_can_convert(self):
493
# format 5 dirs are convertable
494
dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
495
self.assertTrue(dir.can_convert_format())
497
def test_needs_conversion(self):
498
# format 5 dirs need a conversion if they are not the default.
499
# and they start of not the default.
500
old_format = bzrdir.BzrDirFormat.get_default_format()
501
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
503
dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
504
self.assertFalse(dir.needs_format_conversion())
506
bzrdir.BzrDirFormat._set_default_format(old_format)
507
self.assertTrue(dir.needs_format_conversion())
510
class TestFormat6(TestCaseWithTransport):
511
"""Tests specific to the version 6 bzrdir format."""
513
def test_same_lockfiles_between_tree_repo_branch(self):
514
# this checks that only a single lockfiles instance is created
515
# for format 6 objects
516
dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
517
def check_dir_components_use_same_lock(dir):
518
ctrl_1 = dir.open_repository().control_files
519
ctrl_2 = dir.open_branch().control_files
520
ctrl_3 = dir.open_workingtree()._control_files
521
self.assertTrue(ctrl_1 is ctrl_2)
522
self.assertTrue(ctrl_2 is ctrl_3)
523
check_dir_components_use_same_lock(dir)
524
# and if we open it normally.
525
dir = bzrdir.BzrDir.open(self.get_url())
526
check_dir_components_use_same_lock(dir)
528
def test_can_convert(self):
529
# format 6 dirs are convertable
530
dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
531
self.assertTrue(dir.can_convert_format())
533
def test_needs_conversion(self):
534
# format 6 dirs need an conversion if they are not the default.
535
old_format = bzrdir.BzrDirFormat.get_default_format()
536
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirMetaFormat1())
538
dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
539
self.assertTrue(dir.needs_format_conversion())
541
bzrdir.BzrDirFormat._set_default_format(old_format)
544
class NotBzrDir(bzrlib.bzrdir.BzrDir):
545
"""A non .bzr based control directory."""
547
def __init__(self, transport, format):
548
self._format = format
549
self.root_transport = transport
550
self.transport = transport.clone('.not')
553
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat):
554
"""A test class representing any non-.bzr based disk format."""
556
def initialize_on_transport(self, transport):
557
"""Initialize a new .not dir in the base directory of a Transport."""
558
transport.mkdir('.not')
559
return self.open(transport)
561
def open(self, transport):
562
"""Open this directory."""
563
return NotBzrDir(transport, self)
566
def _known_formats(self):
567
return set([NotBzrDirFormat()])
570
def probe_transport(self, transport):
571
"""Our format is present if the transport ends in '.not/'."""
572
if transport.has('.not'):
573
return NotBzrDirFormat()
576
class TestNotBzrDir(TestCaseWithTransport):
577
"""Tests for using the bzrdir api with a non .bzr based disk format.
579
If/when one of these is in the core, we can let the implementation tests
583
def test_create_and_find_format(self):
584
# create a .notbzr dir
585
format = NotBzrDirFormat()
586
dir = format.initialize(self.get_url())
587
self.assertIsInstance(dir, NotBzrDir)
589
bzrlib.bzrdir.BzrDirFormat.register_control_format(format)
591
found = bzrlib.bzrdir.BzrDirFormat.find_format(
592
get_transport(self.get_url()))
593
self.assertIsInstance(found, NotBzrDirFormat)
595
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format)
597
def test_included_in_known_formats(self):
598
bzrlib.bzrdir.BzrDirFormat.register_control_format(NotBzrDirFormat)
600
formats = bzrlib.bzrdir.BzrDirFormat.known_formats()
601
for format in formats:
602
if isinstance(format, NotBzrDirFormat):
604
self.fail("No NotBzrDirFormat in %s" % formats)
606
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(NotBzrDirFormat)
609
class NonLocalTests(TestCaseWithTransport):
610
"""Tests for bzrdir static behaviour on non local paths."""
613
super(NonLocalTests, self).setUp()
614
self.transport_server = MemoryServer
616
def test_create_branch_convenience(self):
617
# outside a repo the default convenience output is a repo+branch_tree
618
format = bzrdir.format_registry.make_bzrdir('knit')
619
branch = bzrdir.BzrDir.create_branch_convenience(
620
self.get_url('foo'), format=format)
621
self.assertRaises(errors.NoWorkingTree,
622
branch.bzrdir.open_workingtree)
623
branch.bzrdir.open_repository()
625
def test_create_branch_convenience_force_tree_not_local_fails(self):
626
# outside a repo the default convenience output is a repo+branch_tree
627
format = bzrdir.format_registry.make_bzrdir('knit')
628
self.assertRaises(errors.NotLocalUrl,
629
bzrdir.BzrDir.create_branch_convenience,
633
t = get_transport(self.get_url('.'))
634
self.assertFalse(t.has('foo'))
636
def test_clone(self):
637
# clone into a nonlocal path works
638
format = bzrdir.format_registry.make_bzrdir('knit')
639
branch = bzrdir.BzrDir.create_branch_convenience('local',
641
branch.bzrdir.open_workingtree()
642
result = branch.bzrdir.clone(self.get_url('remote'))
643
self.assertRaises(errors.NoWorkingTree,
644
result.open_workingtree)
646
result.open_repository()