~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/remote.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    urlutils,
36
36
    )
37
37
from bzrlib.smart import client, medium, protocol
 
38
from bzrlib.symbol_versioning import (deprecated_method, one_four)
38
39
 
39
40
 
40
41
class _SmartStat(object):
104
105
            self._shared_connection = transport._SharedConnection(medium,
105
106
                                                                  credentials,
106
107
                                                                  self.base)
 
108
        else:
 
109
            if medium is None:
 
110
                # No medium was specified, so share the medium from the
 
111
                # _from_transport.
 
112
                medium = self._shared_connection.connection
107
113
 
108
114
        if _client is None:
109
 
            self._client = client._SmartClient(self.get_shared_medium())
 
115
            self._client = client._SmartClient(medium, self.base)
110
116
        else:
111
117
            self._client = _client
112
118
 
121
127
 
122
128
    def is_readonly(self):
123
129
        """Smart server transport can do read/write file operations."""
124
 
        resp = self._call2('Transport.is_readonly')
125
 
        if resp == ('yes', ):
126
 
            return True
127
 
        elif resp == ('no', ):
128
 
            return False
129
 
        elif (resp == ('error', "Generic bzr smart protocol error: "
130
 
                                "bad request 'Transport.is_readonly'") or
131
 
              resp == ('error', "Generic bzr smart protocol error: "
132
 
                                "bad request u'Transport.is_readonly'")):
 
130
        try:
 
131
            resp = self._call2('Transport.is_readonly')
 
132
        except errors.UnknownSmartMethod:
133
133
            # XXX: nasty hack: servers before 0.16 don't have a
134
134
            # 'Transport.is_readonly' verb, so we do what clients before 0.16
135
135
            # did: assume False.
136
136
            return False
 
137
        if resp == ('yes', ):
 
138
            return True
 
139
        elif resp == ('no', ):
 
140
            return False
137
141
        else:
138
142
            self._translate_error(resp)
139
143
        raise errors.UnexpectedSmartServerResponse(resp)
144
148
    def get_smart_medium(self):
145
149
        return self._get_connection()
146
150
 
 
151
    @deprecated_method(one_four)
147
152
    def get_shared_medium(self):
148
153
        return self._get_shared_connection()
149
154