77
77
branch.repository.unlock()
80
class SmartServerBranchBreakLock(SmartServerBranchRequest):
82
def do_with_branch(self, branch):
83
"""Break a branch lock.
86
return SuccessfulSmartServerResponse(('ok', ), )
89
80
class SmartServerBranchGetConfigFile(SmartServerBranchRequest):
91
82
def do_with_branch(self, branch):
94
85
The body is not utf8 decoded - its the literal bytestream from disk.
97
content = branch.control_transport.get_bytes('branch.conf')
88
content = branch._transport.get_bytes('branch.conf')
98
89
except errors.NoSuchFile:
100
91
return SuccessfulSmartServerResponse( ('ok', ), content)
103
class SmartServerBranchPutConfigFile(SmartServerBranchRequest):
104
"""Set the configuration data for a branch.
109
def do_with_branch(self, branch, branch_token, repo_token):
110
"""Set the content of branch.conf.
112
The body is not utf8 decoded - its the literal bytestream for disk.
114
self._branch = branch
115
self._branch_token = branch_token
116
self._repo_token = repo_token
117
# Signal we want a body
120
def do_body(self, body_bytes):
121
self._branch.repository.lock_write(token=self._repo_token)
123
self._branch.lock_write(token=self._branch_token)
125
self._branch.control_transport.put_bytes(
126
'branch.conf', body_bytes)
128
self._branch.unlock()
130
self._branch.repository.unlock()
131
return SuccessfulSmartServerResponse(('ok', ))
134
94
class SmartServerBranchGetParent(SmartServerBranchRequest):
136
96
def do_with_branch(self, branch):
235
195
return SuccessfulSmartServerResponse(('ok', str(revno), last_revision))
238
class SmartServerBranchRequestRevisionIdToRevno(SmartServerBranchRequest):
240
def do_with_branch(self, branch, revid):
241
"""Return branch.revision_id_to_revno().
245
The revno is encoded in decimal, the revision_id is encoded as utf8.
248
dotted_revno = branch.revision_id_to_dotted_revno(revid)
249
except errors.NoSuchRevision:
250
return FailedSmartServerResponse(('NoSuchRevision', revid))
251
return SuccessfulSmartServerResponse(
252
('ok', ) + tuple(map(str, dotted_revno)))
255
198
class SmartServerSetTipRequest(SmartServerLockedBranchRequest):
256
199
"""Base class for handling common branch request logic for requests that
257
200
update the branch tip.
435
378
return SuccessfulSmartServerResponse(('ok',))
438
class SmartServerBranchRequestGetPhysicalLockStatus(SmartServerBranchRequest):
439
"""Get the physical lock status for a branch.
444
def do_with_branch(self, branch):
445
if branch.get_physical_lock_status():
446
return SuccessfulSmartServerResponse(('yes',))
448
return SuccessfulSmartServerResponse(('no',))