56
56
def do(self, path, *args):
57
57
"""Open a BzrDir at path, and return self.do_bzrdir_request(*args)."""
58
self._bzrdir = BzrDir.open_from_transport(
59
self.transport_from_client_path(path))
59
self._bzrdir = BzrDir.open_from_transport(
60
self.transport_from_client_path(path))
61
except errors.NotBranchError:
62
return FailedSmartServerResponse(('nobranch', ))
60
63
return self.do_bzrdir_request(*args)
62
65
def _boolean_to_yes_no(self, a_boolean):
298
301
return SuccessfulSmartServerResponse(('ok', ))
301
class SmartServerRequestOpenBranch(SmartServerRequest):
304
"""try to open a branch at path and return ok/nobranch.
306
If a bzrdir is not present, an exception is propogated
307
rather than 'no branch' because these are different conditions.
309
bzrdir = BzrDir.open_from_transport(
310
self.transport_from_client_path(path))
304
class SmartServerRequestOpenBranch(SmartServerRequestBzrDir):
306
def do_bzrdir_request(self):
307
"""open a branch at path and return the branch reference or branch."""
312
reference_url = bzrdir.get_branch_reference()
309
reference_url = self._bzrdir.get_branch_reference()
313
310
if reference_url is None:
314
311
return SuccessfulSmartServerResponse(('ok', ''))
316
313
return SuccessfulSmartServerResponse(('ok', reference_url))
317
314
except errors.NotBranchError:
318
315
return FailedSmartServerResponse(('nobranch', ))
318
class SmartServerRequestOpenBranchV2(SmartServerRequestBzrDir):
320
def do_bzrdir_request(self):
321
"""open a branch at path and return the reference or format."""
323
reference_url = self._bzrdir.get_branch_reference()
324
if reference_url is None:
325
format = self._bzrdir.open_branch()._format.network_name()
326
return SuccessfulSmartServerResponse(('branch', format))
328
return SuccessfulSmartServerResponse(('ref', reference_url))
329
except errors.NotBranchError:
330
return FailedSmartServerResponse(('nobranch', ))