/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert Collins
  • Date: 2009-02-26 04:25:00 UTC
  • mto: This revision was merged to the branch mainline in revision 4060.
  • Revision ID: robertc@robertcollins.net-20090226042500-xl9urv7zcbvkfjvs
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
            format = BranchReferenceFormat()
220
220
            return format.open(self, _found=True, location=reference_url)
221
221
 
 
222
    def _open_repo_v1(self, path):
 
223
        verb = 'BzrDir.find_repository'
 
224
        response = self._call(verb, path)
 
225
        if response[0] != 'ok':
 
226
            raise errors.UnexpectedSmartServerResponse(response)
 
227
        # servers that only support the v1 method don't support external
 
228
        # references either.
 
229
        self._ensure_real()
 
230
        repo = self._real_bzrdir.open_repository()
 
231
        response = response + ('no', repo._format.network_name())
 
232
        return response, repo
 
233
 
 
234
    def _open_repo_v2(self, path):
 
235
        verb = 'BzrDir.find_repositoryV2'
 
236
        response = self._call(verb, path)
 
237
        if response[0] != 'ok':
 
238
            raise errors.UnexpectedSmartServerResponse(response)
 
239
        self._ensure_real()
 
240
        repo = self._real_bzrdir.open_repository()
 
241
        response = response + (repo._format.network_name(),)
 
242
        return response, repo
 
243
 
 
244
    def _open_repo_v3(self, path):
 
245
        verb = 'BzrDir.find_repositoryV3'
 
246
        response = self._call(verb, path)
 
247
        if response[0] != 'ok':
 
248
            raise errors.UnexpectedSmartServerResponse(response)
 
249
        return response, None
 
250
 
222
251
    def open_repository(self):
223
252
        path = self._path_for_remote_call(self._client)
224
 
        verb = 'BzrDir.find_repositoryV2'
225
 
        try:
226
 
            response = self._call(verb, path)
227
 
        except errors.UnknownSmartMethod:
228
 
            verb = 'BzrDir.find_repository'
229
 
            response = self._call(verb, path)
 
253
        response = None
 
254
        for probe in [self._open_repo_v3, self._open_repo_v2,
 
255
            self._open_repo_v1]:
 
256
            try:
 
257
                response, real_repo = probe(path)
 
258
                break
 
259
            except errors.UnknownSmartMethod:
 
260
                pass
 
261
        if response is None:
 
262
            raise errors.UnknownSmartMethod('BzrDir.find_repository{3,2,}')
230
263
        if response[0] != 'ok':
231
264
            raise errors.UnexpectedSmartServerResponse(response)
232
 
        if verb == 'BzrDir.find_repository':
233
 
            # servers that don't support the V2 method don't support external
234
 
            # references either.
235
 
            response = response + ('no', )
236
 
        if not (len(response) == 5):
 
265
        if len(response) != 6:
237
266
            raise SmartProtocolError('incorrect response length %s' % (response,))
238
267
        if response[1] == '':
239
 
            format = RemoteRepositoryFormat()
240
 
            format.rich_root_data = (response[2] == 'yes')
241
 
            format.supports_tree_reference = (response[3] == 'yes')
242
 
            # No wire format to check this yet.
243
 
            format.supports_external_lookups = (response[4] == 'yes')
 
268
            # repo is at this dir.
 
269
            format = response_tuple_to_repo_format(response[2:])
244
270
            # Used to support creating a real format instance when needed.
245
271
            format._creating_bzrdir = self
246
272
            remote_repo = RemoteRepository(self, format)
247
273
            format._creating_repo = remote_repo
 
274
            if real_repo is not None:
 
275
                remote_repo._set_real_repository(real_repo)
248
276
            return remote_repo
249
277
        else:
250
278
            raise errors.NoRepositoryPresent(self)