2355
2359
return self._real_branch.set_push_location(location)
2362
class RemoteBranchConfig(object):
2363
"""A Config that reads from a smart branch and writes via smart methods.
2365
It is a low-level object that considers config data to be name/value pairs
2366
that may be associated with a section. Assigning meaning to the these
2367
values is done at higher levels like bzrlib.config.TreeConfig.
2370
def __init__(self, branch):
2371
self._branch = branch
2373
def get_option(self, name, section=None, default=None):
2374
"""Return the value associated with a named option.
2376
:param name: The name of the value
2377
:param section: The section the option is in (if any)
2378
:param default: The value to return if the value is not set
2379
:return: The value or default value
2381
configobj = self._get_configobj()
2383
section_obj = configobj
2386
section_obj = configobj[section]
2389
return section_obj.get(name, default)
2391
def _get_configobj(self):
2392
path = self._branch.bzrdir._path_for_remote_call(
2393
self._branch._client)
2394
response = self._branch._client.call_expecting_body(
2395
'Branch.get_config_file', path)
2396
if response[0][0] != 'ok':
2397
raise UnexpectedSmartServerResponse(response)
2398
bytes = response[1].read_body_bytes()
2399
return config.ConfigObj([bytes], encoding='utf-8')
2401
def set_option(self, value, name, section=None):
2402
"""Set the value associated with a named option.
2404
:param value: The value to set
2405
:param name: The name of the value to set
2406
:param section: The section the option is in (if any)
2408
return self._vfs_set_option(value, name, section)
2410
def _vfs_set_option(self, value, name, section=None):
2411
self._branch._ensure_real()
2412
return self._branch._real_branch._get_config().set_option(
2413
value, name, section)
2358
2416
def _extract_tar(tar, to_dir):
2359
2417
"""Extract all the contents of a tarfile object.