~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
466
466
        _unsupported is a private parameter to the BzrDir class.
467
467
        """
468
468
        t = get_transport(base)
469
 
        # mutter("trying to open %r with transport %r", base, t)
470
 
        format = BzrDirFormat.find_format(t)
 
469
        return BzrDir.open_from_transport(t, _unsupported=_unsupported)
 
470
 
 
471
    @staticmethod
 
472
    def open_from_transport(transport, _unsupported=False):
 
473
        """Open a bzrdir within a particular directory.
 
474
 
 
475
        :param transport: Transport containing the bzrdir.
 
476
        :param _unsupported: private.
 
477
        """
 
478
        format = BzrDirFormat.find_format(transport)
471
479
        BzrDir._check_supported(format, _unsupported)
472
 
        return format.open(t, _found=True)
 
480
        return format.open(transport, _found=True)
473
481
 
474
482
    def open_branch(self, unsupported=False):
475
483
        """Open the branch object at this BzrDir if one is present.
509
517
        url = a_transport.base
510
518
        while True:
511
519
            try:
512
 
                format = BzrDirFormat.find_format(a_transport)
513
 
                BzrDir._check_supported(format, False)
514
 
                return format.open(a_transport), urlutils.unescape(a_transport.relpath(url))
 
520
                result = BzrDir.open_from_transport(a_transport)
 
521
                return result, urlutils.unescape(a_transport.relpath(url))
515
522
            except errors.NotBranchError, e:
516
 
                ## mutter('not a branch in: %r %s', a_transport.base, e)
517
523
                pass
518
524
            new_t = a_transport.clone('..')
519
525
            if new_t.base == a_transport.base: