479
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)
482
547
class NonLocalTests(TestCaseWithTransport):
483
548
"""Tests for bzrdir static behaviour on non local paths."""