~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    sha_strings,
57
57
    sha_string,
58
58
    )
59
 
from bzrlib.smart.client import SmartClient
 
59
from bzrlib.smart.client import _SmartClient
60
60
from bzrlib.store.revision.text import TextRevisionStore
61
61
from bzrlib.store.text import TextStore
62
62
from bzrlib.store.versioned import WeaveStore
527
527
        return BzrDir.open_from_transport(t, _unsupported=_unsupported)
528
528
 
529
529
    @staticmethod
530
 
    def open_from_transport(transport, _unsupported=False):
 
530
    def open_from_transport(transport, _unsupported=False,
 
531
                            _server_formats=True):
531
532
        """Open a bzrdir within a particular directory.
532
533
 
533
534
        :param transport: Transport containing the bzrdir.
536
537
        base = transport.base
537
538
 
538
539
        def find_format(transport):
539
 
            return transport, BzrDirFormat.find_format(transport)
 
540
            return transport, BzrDirFormat.find_format(
 
541
                transport, _server_formats=_server_formats)
540
542
 
541
543
        def redirected(transport, e, redirection_notice):
542
544
            qualified_source = e.get_source_url()
653
655
    def open_workingtree(self, _unsupported=False,
654
656
            recommend_upgrade=True):
655
657
        """Open the workingtree object at this BzrDir if one is present.
656
 
        
657
 
        TODO: static convenience version of this?
 
658
 
 
659
        :param recommend_upgrade: Optional keyword parameter, when True (the
 
660
            default), emit through the ui module a recommendation that the user
 
661
            upgrade the working tree when the workingtree being opened is old
 
662
            (but still fully supported).
658
663
        """
659
664
        raise NotImplementedError(self.open_workingtree)
660
665
 
1216
1221
    This is a list of BzrDirFormat objects.
1217
1222
    """
1218
1223
 
 
1224
    _control_server_formats = []
 
1225
    """The registered control server formats, e.g. RemoteBzrDirs.
 
1226
 
 
1227
    This is a list of BzrDirFormat objects.
 
1228
    """
 
1229
 
1219
1230
    _lock_file_name = 'branch-lock'
1220
1231
 
1221
1232
    # _lock_class must be set in subclasses to the lock type, typ.
1222
1233
    # TransportLock or LockDir
1223
1234
 
1224
1235
    @classmethod
1225
 
    def find_format(klass, transport):
 
1236
    def find_format(klass, transport, _server_formats=True):
1226
1237
        """Return the format present at transport."""
1227
 
        for format in klass._control_formats:
 
1238
        if _server_formats:
 
1239
            formats = klass._control_server_formats + klass._control_formats
 
1240
        else:
 
1241
            formats = klass._control_formats
 
1242
        for format in formats:
1228
1243
            try:
1229
1244
                return format.probe_transport(transport)
1230
1245
            except errors.NotBranchError:
1380
1395
        klass._control_formats.append(format)
1381
1396
 
1382
1397
    @classmethod
 
1398
    def register_control_server_format(klass, format):
 
1399
        """Register a control format for client-server environments.
 
1400
 
 
1401
        These formats will be tried before ones registered with
 
1402
        register_control_format.  This gives implementations that decide to the
 
1403
        chance to grab it before anything looks at the contents of the format
 
1404
        file.
 
1405
        """
 
1406
        klass._control_server_formats.append(format)
 
1407
 
 
1408
    @classmethod
1383
1409
    @symbol_versioning.deprecated_method(symbol_versioning.zero_fourteen)
1384
1410
    def set_default_format(klass, format):
1385
1411
        klass._set_default_format(format)
2225
2251
            # TODO: lookup the local format from a server hint.
2226
2252
            local_dir_format = BzrDirMetaFormat1()
2227
2253
            return local_dir_format.initialize_on_transport(transport)
2228
 
        client = SmartClient(medium)
 
2254
        client = _SmartClient(medium)
2229
2255
        path = client.remote_path_from_transport(transport)
2230
 
        response = SmartClient(medium).call('BzrDirFormat.initialize', path)
 
2256
        response = _SmartClient(medium).call('BzrDirFormat.initialize', path)
2231
2257
        assert response[0] in ('ok', ), 'unexpected response code %s' % (response,)
2232
2258
        return remote.RemoteBzrDir(transport)
2233
2259
 
2240
2266
        return self.get_format_description() == other.get_format_description()
2241
2267
 
2242
2268
 
2243
 
# We can't use register_control_format because it adds it at a lower priority
2244
 
# than the existing branches, whereas this should take priority.
2245
 
BzrDirFormat._control_formats.insert(0, RemoteBzrDirFormat)
 
2269
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
2246
2270
 
2247
2271
 
2248
2272
class BzrDirFormatInfo(object):