465
465
bzrdir.BzrDirFormat.set_default_format(old_format)
468
class NotBzrDir(bzrlib.bzrdir.BzrDir):
469
"""A non .bzr based control directory."""
471
def __init__(self, transport, format):
472
self._format = format
473
self.root_transport = transport
474
self.transport = transport.clone('.not')
477
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat):
478
"""A test class representing any non-.bzr based disk format."""
480
def initialize_on_transport(self, transport):
481
"""Initialize a new .not dir in the base directory of a Transport."""
482
transport.mkdir('.not')
483
return self.open(transport)
485
def open(self, transport):
486
"""Open this directory."""
487
return NotBzrDir(transport, self)
490
def probe_transport(self, transport):
491
"""Our format is present if the transport ends in '.not/'."""
492
if transport.base.endswith('.not/'):
493
return NotBzrDirFormat()
496
class TestNotBzrDir(TestCaseWithTransport):
497
"""Tests for using the bzrdir api with a non .bzr based disk format.
499
If/when one of these is in the core, we can let the implementation tests
503
def test_create_and_find_format(self):
504
# create a .notbzr dir
505
format = NotBzrDirFormat()
506
dir = format.initialize(self.get_url())
507
self.assertIsInstance(dir, NotBzrDir)
509
bzrlib.bzrdir.BzrDirFormat.register_control_format(format)
511
found = bzrlib.bzrdir.BzrDirFormat.find_format(
512
get_transport(self.get_url()))
514
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format)
468
517
class NonLocalTests(TestCaseWithTransport):
469
518
"""Tests for bzrdir static behaviour on non local paths."""