~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Robert Collins
  • Date: 2006-05-30 12:47:26 UTC
  • mto: (1769.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1770.
  • Revision ID: robertc@robertcollins.net-20060530124726-1452571a34787c78
Support non '.bzr' control directories in bzrdir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
465
465
            bzrdir.BzrDirFormat.set_default_format(old_format)
466
466
 
467
467
 
 
468
class NotBzrDir(bzrlib.bzrdir.BzrDir):
 
469
    """A non .bzr based control directory."""
 
470
 
 
471
    def __init__(self, transport, format):
 
472
        self._format = format
 
473
        self.root_transport = transport
 
474
        self.transport = transport.clone('.not')
 
475
 
 
476
 
 
477
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat):
 
478
    """A test class representing any non-.bzr based disk format."""
 
479
 
 
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)
 
484
 
 
485
    def open(self, transport):
 
486
        """Open this directory."""
 
487
        return NotBzrDir(transport, self)
 
488
 
 
489
    @classmethod
 
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()
 
494
 
 
495
 
 
496
class TestNotBzrDir(TestCaseWithTransport):
 
497
    """Tests for using the bzrdir api with a non .bzr based disk format.
 
498
    
 
499
    If/when one of these is in the core, we can let the implementation tests
 
500
    verify this works.
 
501
    """
 
502
 
 
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)
 
508
        # now probe for it.
 
509
        bzrlib.bzrdir.BzrDirFormat.register_control_format(format)
 
510
        try:
 
511
            found = bzrlib.bzrdir.BzrDirFormat.find_format(
 
512
                get_transport(self.get_url()))
 
513
        finally:
 
514
            bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format)
 
515
 
 
516
 
468
517
class NonLocalTests(TestCaseWithTransport):
469
518
    """Tests for bzrdir static behaviour on non local paths."""
470
519