55
56
return SuccessfulSmartServerResponse((answer,))
58
class SmartServerRequestOpenBzrDir_2_1(SmartServerRequest):
61
"""Is there a BzrDir present, and if so does it have a working tree?
66
t = self.transport_from_client_path(path)
67
except errors.PathNotChild:
68
# The client is trying to ask about a path that they have no access
70
return SuccessfulSmartServerResponse(('no',))
72
bd = BzrDir.open_from_transport(t)
73
except errors.NotBranchError:
77
if bd.has_workingtree():
81
return SuccessfulSmartServerResponse(answer)
84
59
class SmartServerRequestBzrDir(SmartServerRequest):
86
61
def do(self, path, *args):
89
64
self._bzrdir = BzrDir.open_from_transport(
90
65
self.transport_from_client_path(path))
91
except errors.NotBranchError, e:
92
return FailedSmartServerResponse(('nobranch',))
66
except errors.NotBranchError:
67
return FailedSmartServerResponse(('nobranch', ))
93
68
return self.do_bzrdir_request(*args)
95
70
def _boolean_to_yes_no(self, a_boolean):
465
440
return SuccessfulSmartServerResponse(('ok', ''))
467
442
return SuccessfulSmartServerResponse(('ok', reference_url))
468
except errors.NotBranchError, e:
469
return FailedSmartServerResponse(('nobranch',))
443
except errors.NotBranchError:
444
return FailedSmartServerResponse(('nobranch', ))
472
447
class SmartServerRequestOpenBranchV2(SmartServerRequestBzrDir):
481
456
return SuccessfulSmartServerResponse(('branch', format))
483
458
return SuccessfulSmartServerResponse(('ref', reference_url))
484
except errors.NotBranchError, e:
485
return FailedSmartServerResponse(('nobranch',))
488
class SmartServerRequestOpenBranchV3(SmartServerRequestBzrDir):
490
def do_bzrdir_request(self):
491
"""Open a branch at path and return the reference or format.
493
This version introduced in 2.1.
495
Differences to SmartServerRequestOpenBranchV2:
496
* can return 2-element ('nobranch', extra), where 'extra' is a string
497
with an explanation like 'location is a repository'. Previously
498
a 'nobranch' response would never have more than one element.
501
reference_url = self._bzrdir.get_branch_reference()
502
if reference_url is None:
503
br = self._bzrdir.open_branch(ignore_fallbacks=True)
504
format = br._format.network_name()
505
return SuccessfulSmartServerResponse(('branch', format))
507
return SuccessfulSmartServerResponse(('ref', reference_url))
508
except errors.NotBranchError, e:
509
# Stringify the exception so that its .detail attribute will be
515
if detail.startswith(': '):
518
return FailedSmartServerResponse(resp)
459
except errors.NotBranchError:
460
return FailedSmartServerResponse(('nobranch', ))