219
219
format = BranchReferenceFormat()
220
220
return format.open(self, _found=True, location=reference_url)
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
230
repo = self._real_bzrdir.open_repository()
231
response = response + ('no', repo._format.network_name())
232
return response, repo
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)
240
repo = self._real_bzrdir.open_repository()
241
response = response + (repo._format.network_name(),)
242
return response, repo
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
222
251
def open_repository(self):
223
252
path = self._path_for_remote_call(self._client)
224
verb = 'BzrDir.find_repositoryV2'
226
response = self._call(verb, path)
227
except errors.UnknownSmartMethod:
228
verb = 'BzrDir.find_repository'
229
response = self._call(verb, path)
254
for probe in [self._open_repo_v3, self._open_repo_v2,
257
response, real_repo = probe(path)
259
except errors.UnknownSmartMethod:
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
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
250
278
raise errors.NoRepositoryPresent(self)