4179
4182
reconciler = BranchReconciler(self, thorough=thorough)
4180
4183
return reconciler.reconcile()
4182
def set_reference_info(self, tree_path, branch_location, file_id=None):
4183
raise errors.UnsupportedOperation(self.set_reference_info, self)
4185
def get_reference_info(self, tree_path):
4186
raise errors.UnsupportedOperation(self.get_reference_info, self)
4185
def get_reference_info(self, file_id):
4186
"""Get the tree_path and branch_location for a tree reference."""
4187
if not self._format.supports_reference_locations:
4188
raise errors.UnsupportedOperation(self.get_reference_info, self)
4189
return self._get_all_reference_info().get(file_id, (None, None))
4191
def set_reference_info(self, file_id, branch_location, tree_path=None):
4192
"""Set the branch location to use for a tree reference."""
4193
if not self._format.supports_reference_locations:
4194
raise errors.UnsupportedOperation(self.set_reference_info, self)
4196
self._real_branch.set_reference_info(
4197
file_id, branch_location, tree_path)
4199
def _set_all_reference_info(self, reference_info):
4200
if not self._format.supports_reference_locations:
4201
raise errors.UnsupportedOperation(self.set_reference_info, self)
4203
self._real_branch._set_all_reference_info(reference_info)
4188
4205
def _get_all_reference_info(self):
4190
return self._real_branch._get_all_reference_info()
4206
if not self._format.supports_reference_locations:
4209
response, handler = self._call_expecting_body(
4210
b'Branch.get_all_reference_info', self._remote_path())
4211
except errors.UnknownSmartMethod:
4213
return self._real_branch._get_all_reference_info()
4214
if len(response) and response[0] != b'ok':
4215
raise errors.UnexpectedSmartServerResponse(response)
4217
for (f, u, p) in bencode.bdecode(handler.read_body_bytes()):
4218
ret[f] = (u.decode('utf-8'), p.decode('utf-8') if p else None)
4192
def reference_parent(self, path, possible_transports=None):
4221
def reference_parent(self, file_id, path, possible_transports=None):
4193
4222
"""Return the parent branch for a tree-reference.
4195
4224
:param path: The path of the nested tree in the tree
4196
4225
:return: A branch associated with the nested tree
4198
branch_location = self.get_reference_info(path)[0]
4227
branch_location = self.get_reference_info(file_id)[0]
4199
4228
if branch_location is None:
4200
return BzrBranch.reference_parent(self, path, possible_transports)
4201
branch_location = urlutils.join(self.user_url, branch_location)
4202
return Branch.open(branch_location,
4203
possible_transports=possible_transports)
4230
return branch.Branch.open_from_transport(
4231
self.controldir.root_transport.clone(path),
4232
possible_transports=possible_transports)
4233
except errors.NotBranchError:
4235
return branch.Branch.open(
4237
urlutils.strip_segment_parameters(self.user_url), branch_location),
4238
possible_transports=possible_transports)
4206
4241
class RemoteConfig(object):