45
45
bzrdir.BzrDirFormat.set_default_format(SampleBzrDirFormat())
46
46
# creating a bzr dir should now create an instrumented dir.
48
result = bzrdir.BzrDir.create('memory:/')
48
result = bzrdir.BzrDir.create('memory:///')
49
49
self.failUnless(isinstance(result, SampleBzrDir))
51
51
bzrdir.BzrDirFormat.set_default_format(old_format)
255
255
bzrdir.BzrDirFormat.set_default_format(old_format)
257
def test_create_branch_convenience_root(self):
258
"""Creating a branch at the root of a fs should work."""
259
self.transport_server = MemoryServer
260
# outside a repo the default convenience output is a repo+branch_tree
261
old_format = bzrdir.BzrDirFormat.get_default_format()
262
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
264
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url())
265
self.assertRaises(errors.NoWorkingTree,
266
branch.bzrdir.open_workingtree)
267
branch.bzrdir.open_repository()
269
bzrdir.BzrDirFormat.set_default_format(old_format)
257
271
def test_create_branch_convenience_under_shared_repo(self):
258
272
# inside a repo the default convenience output is a branch+ follow the
259
273
# repo tree policy
465
479
bzrdir.BzrDirFormat.set_default_format(old_format)
482
class NotBzrDir(bzrlib.bzrdir.BzrDir):
483
"""A non .bzr based control directory."""
485
def __init__(self, transport, format):
486
self._format = format
487
self.root_transport = transport
488
self.transport = transport.clone('.not')
491
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat):
492
"""A test class representing any non-.bzr based disk format."""
494
def initialize_on_transport(self, transport):
495
"""Initialize a new .not dir in the base directory of a Transport."""
496
transport.mkdir('.not')
497
return self.open(transport)
499
def open(self, transport):
500
"""Open this directory."""
501
return NotBzrDir(transport, self)
504
def _known_formats(self):
505
return set([NotBzrDirFormat()])
508
def probe_transport(self, transport):
509
"""Our format is present if the transport ends in '.not/'."""
510
if transport.has('.not'):
511
return NotBzrDirFormat()
514
class TestNotBzrDir(TestCaseWithTransport):
515
"""Tests for using the bzrdir api with a non .bzr based disk format.
517
If/when one of these is in the core, we can let the implementation tests
521
def test_create_and_find_format(self):
522
# create a .notbzr dir
523
format = NotBzrDirFormat()
524
dir = format.initialize(self.get_url())
525
self.assertIsInstance(dir, NotBzrDir)
527
bzrlib.bzrdir.BzrDirFormat.register_control_format(format)
529
found = bzrlib.bzrdir.BzrDirFormat.find_format(
530
get_transport(self.get_url()))
531
self.assertIsInstance(found, NotBzrDirFormat)
533
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format)
535
def test_included_in_known_formats(self):
536
bzrlib.bzrdir.BzrDirFormat.register_control_format(NotBzrDirFormat)
538
formats = bzrlib.bzrdir.BzrDirFormat.known_formats()
539
for format in formats:
540
if isinstance(format, NotBzrDirFormat):
542
self.fail("No NotBzrDirFormat in %s" % formats)
544
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(NotBzrDirFormat)
468
547
class NonLocalTests(TestCaseWithTransport):
469
548
"""Tests for bzrdir static behaviour on non local paths."""