104
110
self._client = client._SmartClient(medium)
106
112
self._client = _client
119
return '%s(%r)' % (self.__class__.__name__, self._client)
121
def _probe_bzrdir(self):
122
medium = self._client._medium
109
123
path = self._path_for_remote_call(self._client)
124
if medium._is_remote_before((2, 1)):
128
self._rpc_open_2_1(path)
130
except errors.UnknownSmartMethod:
131
medium._remember_remote_is_before((2, 1))
134
def _rpc_open_2_1(self, path):
135
response = self._call('BzrDir.open_2.1', path)
136
if response == ('no',):
137
raise errors.NotBranchError(path=self.root_transport.base)
138
elif response[0] == 'yes':
139
if response[1] == 'yes':
140
self._has_working_tree = True
141
elif response[1] == 'no':
142
self._has_working_tree = False
144
raise errors.UnexpectedSmartServerResponse(response)
146
raise errors.UnexpectedSmartServerResponse(response)
148
def _rpc_open(self, path):
110
149
response = self._call('BzrDir.open', path)
111
150
if response not in [('yes',), ('no',)]:
112
151
raise errors.UnexpectedSmartServerResponse(response)
113
152
if response == ('no',):
114
raise errors.NotBranchError(path=transport.base)
153
raise errors.NotBranchError(path=self.root_transport.base)
116
155
def _ensure_real(self):
117
156
"""Ensure that there is a _real_bzrdir set.
245
290
def _get_branch_reference(self):
246
291
path = self._path_for_remote_call(self._client)
247
292
medium = self._client._medium
248
if not medium._is_remote_before((1, 13)):
294
('BzrDir.open_branchV3', (2, 1)),
295
('BzrDir.open_branchV2', (1, 13)),
296
('BzrDir.open_branch', None),
298
for verb, required_version in candidate_calls:
299
if required_version and medium._is_remote_before(required_version):
250
response = self._call('BzrDir.open_branchV2', path)
251
if response[0] not in ('ref', 'branch'):
252
raise errors.UnexpectedSmartServerResponse(response)
302
response = self._call(verb, path)
254
303
except errors.UnknownSmartMethod:
255
medium._remember_remote_is_before((1, 13))
256
response = self._call('BzrDir.open_branch', path)
257
if response[0] != 'ok':
304
if required_version is None:
306
medium._remember_remote_is_before(required_version)
309
if verb == 'BzrDir.open_branch':
310
if response[0] != 'ok':
311
raise errors.UnexpectedSmartServerResponse(response)
312
if response[1] != '':
313
return ('ref', response[1])
315
return ('branch', '')
316
if response[0] not in ('ref', 'branch'):
258
317
raise errors.UnexpectedSmartServerResponse(response)
259
if response[1] != '':
260
return ('ref', response[1])
262
return ('branch', '')
264
320
def _get_tree_branch(self):
265
321
"""See BzrDir._get_tree_branch()."""
266
322
return None, self.open_branch()
268
def open_branch(self, _unsupported=False, ignore_fallbacks=False):
324
def open_branch(self, name=None, unsupported=False,
325
ignore_fallbacks=False):
270
327
raise NotImplementedError('unsupported flag support not implemented yet.')
271
328
if self._next_open_branch_result is not None:
272
329
# See create_branch for details.
665
751
self._ensure_real()
666
752
return self._real_repository.suspend_write_group()
754
def get_missing_parent_inventories(self, check_for_missing_texts=True):
756
return self._real_repository.get_missing_parent_inventories(
757
check_for_missing_texts=check_for_missing_texts)
759
def _get_rev_id_for_revno_vfs(self, revno, known_pair):
761
return self._real_repository.get_rev_id_for_revno(
764
def get_rev_id_for_revno(self, revno, known_pair):
765
"""See Repository.get_rev_id_for_revno."""
766
path = self.bzrdir._path_for_remote_call(self._client)
768
if self._client._medium._is_remote_before((1, 17)):
769
return self._get_rev_id_for_revno_vfs(revno, known_pair)
770
response = self._call(
771
'Repository.get_rev_id_for_revno', path, revno, known_pair)
772
except errors.UnknownSmartMethod:
773
self._client._medium._remember_remote_is_before((1, 17))
774
return self._get_rev_id_for_revno_vfs(revno, known_pair)
775
if response[0] == 'ok':
776
return True, response[1]
777
elif response[0] == 'history-incomplete':
778
known_pair = response[1:3]
779
for fallback in self._fallback_repositories:
780
found, result = fallback.get_rev_id_for_revno(revno, known_pair)
785
# Not found in any fallbacks
786
return False, known_pair
788
raise errors.UnexpectedSmartServerResponse(response)
668
790
def _ensure_real(self):
669
791
"""Ensure that there is a _real_repository set.
744
871
"""Return a source for streaming from this repository."""
745
872
return RemoteStreamSource(self, to_format)
747
875
def has_revision(self, revision_id):
748
"""See Repository.has_revision()."""
749
if revision_id == NULL_REVISION:
750
# The null revision is always present.
752
path = self.bzrdir._path_for_remote_call(self._client)
753
response = self._call('Repository.has_revision', path, revision_id)
754
if response[0] not in ('yes', 'no'):
755
raise errors.UnexpectedSmartServerResponse(response)
756
if response[0] == 'yes':
758
for fallback_repo in self._fallback_repositories:
759
if fallback_repo.has_revision(revision_id):
876
"""True if this repository has a copy of the revision."""
877
# Copy of bzrlib.repository.Repository.has_revision
878
return revision_id in self.has_revisions((revision_id,))
763
881
def has_revisions(self, revision_ids):
764
"""See Repository.has_revisions()."""
765
# FIXME: This does many roundtrips, particularly when there are
766
# fallback repositories. -- mbp 20080905
768
for revision_id in revision_ids:
769
if self.has_revision(revision_id):
770
result.add(revision_id)
882
"""Probe to find out the presence of multiple revisions.
884
:param revision_ids: An iterable of revision_ids.
885
:return: A set of the revision_ids that were present.
887
# Copy of bzrlib.repository.Repository.has_revisions
888
parent_map = self.get_parent_map(revision_ids)
889
result = set(parent_map)
890
if _mod_revision.NULL_REVISION in revision_ids:
891
result.add(_mod_revision.NULL_REVISION)
894
def _has_same_fallbacks(self, other_repo):
895
"""Returns true if the repositories have the same fallbacks."""
896
# XXX: copied from Repository; it should be unified into a base class
897
# <https://bugs.edge.launchpad.net/bzr/+bug/401622>
898
my_fb = self._fallback_repositories
899
other_fb = other_repo._fallback_repositories
900
if len(my_fb) != len(other_fb):
902
for f, g in zip(my_fb, other_fb):
903
if not f.has_same_location(g):
773
907
def has_same_location(self, other):
908
# TODO: Move to RepositoryBase and unify with the regular Repository
909
# one; unfortunately the tests rely on slightly different behaviour at
910
# present -- mbp 20090710
774
911
return (self.__class__ is other.__class__ and
775
912
self.bzrdir.transport.base == other.bzrdir.transport.base)
921
1080
if isinstance(repository, RemoteRepository):
922
1081
raise AssertionError()
923
1082
self._real_repository = repository
924
# If the _real_repository has _fallback_repositories, clear them out,
925
# because we want it to have the same set as this repository. This is
926
# reasonable to do because the fallbacks we clear here are from a
927
# "real" branch, and we're about to replace them with the equivalents
928
# from a RemoteBranch.
929
self._real_repository._fallback_repositories = []
1083
# three code paths happen here:
1084
# 1) old servers, RemoteBranch.open() calls _ensure_real before setting
1085
# up stacking. In this case self._fallback_repositories is [], and the
1086
# real repo is already setup. Preserve the real repo and
1087
# RemoteRepository.add_fallback_repository will avoid adding
1089
# 2) new servers, RemoteBranch.open() sets up stacking, and when
1090
# ensure_real is triggered from a branch, the real repository to
1091
# set already has a matching list with separate instances, but
1092
# as they are also RemoteRepositories we don't worry about making the
1093
# lists be identical.
1094
# 3) new servers, RemoteRepository.ensure_real is triggered before
1095
# RemoteBranch.ensure real, in this case we get a repo with no fallbacks
1096
# and need to populate it.
1097
if (self._fallback_repositories and
1098
len(self._real_repository._fallback_repositories) !=
1099
len(self._fallback_repositories)):
1100
if len(self._real_repository._fallback_repositories):
1101
raise AssertionError(
1102
"cannot cleanly remove existing _fallback_repositories")
930
1103
for fb in self._fallback_repositories:
931
1104
self._real_repository.add_fallback_repository(fb)
932
1105
if self._lock_mode == 'w':
1056
1234
# We need to accumulate additional repositories here, to pass them in
1057
1235
# on various RPC's.
1237
if self.is_locked():
1238
# We will call fallback.unlock() when we transition to the unlocked
1239
# state, so always add a lock here. If a caller passes us a locked
1240
# repository, they are responsible for unlocking it later.
1241
repository.lock_read()
1059
1242
self._fallback_repositories.append(repository)
1060
1243
# If self._real_repository was parameterised already (e.g. because a
1061
1244
# _real_branch had its get_stacked_on_url method called), then the
1062
1245
# repository to be added may already be in the _real_repositories list.
1063
1246
if self._real_repository is not None:
1064
if repository not in self._real_repository._fallback_repositories:
1247
fallback_locations = [repo.user_url for repo in
1248
self._real_repository._fallback_repositories]
1249
if repository.user_url not in fallback_locations:
1065
1250
self._real_repository.add_fallback_repository(repository)
1067
# They are also seen by the fallback repository. If it doesn't
1068
# exist yet they'll be added then. This implicitly copies them.
1071
1252
def add_inventory(self, revid, inv, parents):
1072
1253
self._ensure_real()
1073
1254
return self._real_repository.add_inventory(revid, inv, parents)
1075
1256
def add_inventory_by_delta(self, basis_revision_id, delta, new_revision_id,
1257
parents, basis_inv=None, propagate_caches=False):
1077
1258
self._ensure_real()
1078
1259
return self._real_repository.add_inventory_by_delta(basis_revision_id,
1079
delta, new_revision_id, parents)
1260
delta, new_revision_id, parents, basis_inv=basis_inv,
1261
propagate_caches=propagate_caches)
1081
1263
def add_revision(self, rev_id, rev, inv=None, config=None):
1082
1264
self._ensure_real()
1580
1770
def insert_stream(self, stream, src_format, resume_tokens):
1581
1771
target = self.target_repo
1772
target._unstacked_provider.missing_keys.clear()
1773
candidate_calls = [('Repository.insert_stream_1.19', (1, 19))]
1582
1774
if target._lock_token:
1583
verb = 'Repository.insert_stream_locked'
1584
extra_args = (target._lock_token or '',)
1585
required_version = (1, 14)
1775
candidate_calls.append(('Repository.insert_stream_locked', (1, 14)))
1776
lock_args = (target._lock_token or '',)
1587
verb = 'Repository.insert_stream'
1589
required_version = (1, 13)
1778
candidate_calls.append(('Repository.insert_stream', (1, 13)))
1590
1780
client = target._client
1591
1781
medium = client._medium
1592
if medium._is_remote_before(required_version):
1593
# No possible way this can work.
1594
return self._insert_real(stream, src_format, resume_tokens)
1595
1782
path = target.bzrdir._path_for_remote_call(client)
1596
if not resume_tokens:
1597
# XXX: Ugly but important for correctness, *will* be fixed during
1598
# 1.13 cycle. Pushing a stream that is interrupted results in a
1599
# fallback to the _real_repositories sink *with a partial stream*.
1600
# Thats bad because we insert less data than bzr expected. To avoid
1601
# this we do a trial push to make sure the verb is accessible, and
1602
# do not fallback when actually pushing the stream. A cleanup patch
1603
# is going to look at rewinding/restarting the stream/partial
1783
# Probe for the verb to use with an empty stream before sending the
1784
# real stream to it. We do this both to avoid the risk of sending a
1785
# large request that is then rejected, and because we don't want to
1786
# implement a way to buffer, rewind, or restart the stream.
1788
for verb, required_version in candidate_calls:
1789
if medium._is_remote_before(required_version):
1792
# We've already done the probing (and set _is_remote_before) on
1793
# a previous insert.
1605
1796
byte_stream = smart_repo._stream_to_byte_stream([], src_format)
1607
1798
response = client.call_with_body_stream(
1608
(verb, path, '') + extra_args, byte_stream)
1799
(verb, path, '') + lock_args, byte_stream)
1609
1800
except errors.UnknownSmartMethod:
1610
1801
medium._remember_remote_is_before(required_version)
1611
return self._insert_real(stream, src_format, resume_tokens)
1807
return self._insert_real(stream, src_format, resume_tokens)
1808
self._last_inv_record = None
1809
self._last_substream = None
1810
if required_version < (1, 19):
1811
# Remote side doesn't support inventory deltas. Wrap the stream to
1812
# make sure we don't send any. If the stream contains inventory
1813
# deltas we'll interrupt the smart insert_stream request and
1815
stream = self._stop_stream_if_inventory_delta(stream)
1612
1816
byte_stream = smart_repo._stream_to_byte_stream(
1613
1817
stream, src_format)
1614
1818
resume_tokens = ' '.join(resume_tokens)
1615
1819
response = client.call_with_body_stream(
1616
(verb, path, resume_tokens) + extra_args, byte_stream)
1820
(verb, path, resume_tokens) + lock_args, byte_stream)
1617
1821
if response[0][0] not in ('ok', 'missing-basis'):
1618
1822
raise errors.UnexpectedSmartServerResponse(response)
1823
if self._last_substream is not None:
1824
# The stream included an inventory-delta record, but the remote
1825
# side isn't new enough to support them. So we need to send the
1826
# rest of the stream via VFS.
1827
self.target_repo.refresh_data()
1828
return self._resume_stream_with_vfs(response, src_format)
1619
1829
if response[0][0] == 'missing-basis':
1620
1830
tokens, missing_keys = bencode.bdecode_as_tuple(response[0][1])
1621
1831
resume_tokens = tokens
1622
return resume_tokens, missing_keys
1832
return resume_tokens, set(missing_keys)
1624
1834
self.target_repo.refresh_data()
1625
1835
return [], set()
1837
def _resume_stream_with_vfs(self, response, src_format):
1838
"""Resume sending a stream via VFS, first resending the record and
1839
substream that couldn't be sent via an insert_stream verb.
1841
if response[0][0] == 'missing-basis':
1842
tokens, missing_keys = bencode.bdecode_as_tuple(response[0][1])
1843
# Ignore missing_keys, we haven't finished inserting yet
1846
def resume_substream():
1847
# Yield the substream that was interrupted.
1848
for record in self._last_substream:
1850
self._last_substream = None
1851
def resume_stream():
1852
# Finish sending the interrupted substream
1853
yield ('inventory-deltas', resume_substream())
1854
# Then simply continue sending the rest of the stream.
1855
for substream_kind, substream in self._last_stream:
1856
yield substream_kind, substream
1857
return self._insert_real(resume_stream(), src_format, tokens)
1859
def _stop_stream_if_inventory_delta(self, stream):
1860
"""Normally this just lets the original stream pass-through unchanged.
1862
However if any 'inventory-deltas' substream occurs it will stop
1863
streaming, and store the interrupted substream and stream in
1864
self._last_substream and self._last_stream so that the stream can be
1865
resumed by _resume_stream_with_vfs.
1868
stream_iter = iter(stream)
1869
for substream_kind, substream in stream_iter:
1870
if substream_kind == 'inventory-deltas':
1871
self._last_substream = substream
1872
self._last_stream = stream_iter
1875
yield substream_kind, substream
1628
1878
class RemoteStreamSource(repository.StreamSource):
1629
1879
"""Stream data from a remote server."""
1669
1935
return self._real_stream(repo, search)
1670
1936
client = repo._client
1671
1937
medium = client._medium
1672
if medium._is_remote_before((1, 13)):
1673
# streaming was added in 1.13
1674
return self._real_stream(repo, search)
1675
1938
path = repo.bzrdir._path_for_remote_call(client)
1677
search_bytes = repo._serialise_search_result(search)
1678
response = repo._call_with_body_bytes_expecting_body(
1679
'Repository.get_stream',
1680
(path, self.to_format.network_name()), search_bytes)
1681
response_tuple, response_handler = response
1682
except errors.UnknownSmartMethod:
1683
medium._remember_remote_is_before((1,13))
1939
search_bytes = repo._serialise_search_result(search)
1940
args = (path, self.to_format.network_name())
1942
('Repository.get_stream_1.19', (1, 19)),
1943
('Repository.get_stream', (1, 13))]
1945
for verb, version in candidate_verbs:
1946
if medium._is_remote_before(version):
1949
response = repo._call_with_body_bytes_expecting_body(
1950
verb, args, search_bytes)
1951
except errors.UnknownSmartMethod:
1952
medium._remember_remote_is_before(version)
1954
response_tuple, response_handler = response
1684
1958
return self._real_stream(repo, search)
1685
1959
if response_tuple[0] != 'ok':
1686
1960
raise errors.UnexpectedSmartServerResponse(response_tuple)
1766
2041
self._network_name)
1768
2043
def get_format_description(self):
1769
return 'Remote BZR Branch'
2045
return 'Remote: ' + self._custom_format.get_format_description()
1771
2047
def network_name(self):
1772
2048
return self._network_name
1774
def open(self, a_bzrdir, ignore_fallbacks=False):
1775
return a_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks)
2050
def open(self, a_bzrdir, name=None, ignore_fallbacks=False):
2051
return a_bzrdir.open_branch(name=name,
2052
ignore_fallbacks=ignore_fallbacks)
1777
def _vfs_initialize(self, a_bzrdir):
2054
def _vfs_initialize(self, a_bzrdir, name):
1778
2055
# Initialisation when using a local bzrdir object, or a non-vfs init
1779
2056
# method is not available on the server.
1780
2057
# self._custom_format is always set - the start of initialize ensures
1782
2059
if isinstance(a_bzrdir, RemoteBzrDir):
1783
2060
a_bzrdir._ensure_real()
1784
result = self._custom_format.initialize(a_bzrdir._real_bzrdir)
2061
result = self._custom_format.initialize(a_bzrdir._real_bzrdir,
1786
2064
# We assume the bzrdir is parameterised; it may not be.
1787
result = self._custom_format.initialize(a_bzrdir)
2065
result = self._custom_format.initialize(a_bzrdir, name)
1788
2066
if (isinstance(a_bzrdir, RemoteBzrDir) and
1789
2067
not isinstance(result, RemoteBranch)):
1790
result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result)
2068
result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result,
1793
def initialize(self, a_bzrdir):
2072
def initialize(self, a_bzrdir, name=None):
1794
2073
# 1) get the network name to use.
1795
2074
if self._custom_format:
1796
2075
network_name = self._custom_format.network_name()
1802
2081
network_name = reference_format.network_name()
1803
2082
# Being asked to create on a non RemoteBzrDir:
1804
2083
if not isinstance(a_bzrdir, RemoteBzrDir):
1805
return self._vfs_initialize(a_bzrdir)
2084
return self._vfs_initialize(a_bzrdir, name=name)
1806
2085
medium = a_bzrdir._client._medium
1807
2086
if medium._is_remote_before((1, 13)):
1808
return self._vfs_initialize(a_bzrdir)
2087
return self._vfs_initialize(a_bzrdir, name=name)
1809
2088
# Creating on a remote bzr dir.
1810
2089
# 2) try direct creation via RPC
1811
2090
path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
2091
if name is not None:
2092
# XXX JRV20100304: Support creating colocated branches
2093
raise errors.NoColocatedBranchSupport(self)
1812
2094
verb = 'BzrDir.create_branch'
1814
2096
response = a_bzrdir._call(verb, path, network_name)
1815
2097
except errors.UnknownSmartMethod:
1816
2098
# Fallback - use vfs methods
1817
2099
medium._remember_remote_is_before((1, 13))
1818
return self._vfs_initialize(a_bzrdir)
2100
return self._vfs_initialize(a_bzrdir, name=name)
1819
2101
if response[0] != 'ok':
1820
2102
raise errors.UnexpectedSmartServerResponse(response)
1821
2103
# Turn the response into a RemoteRepository object.
2277
2611
self._ensure_real()
2278
2612
return self._real_branch._get_parent_location()
2280
def set_parent(self, url):
2282
return self._real_branch.set_parent(url)
2284
2614
def _set_parent_location(self, url):
2285
# Used by tests, to poke bad urls into branch configurations
2287
self.set_parent(url)
2290
return self._real_branch._set_parent_location(url)
2292
def set_stacked_on_url(self, stacked_location):
2293
"""Set the URL this branch is stacked against.
2295
:raises UnstackableBranchFormat: If the branch does not support
2297
:raises UnstackableRepositoryFormat: If the repository does not support
2615
medium = self._client._medium
2616
if medium._is_remote_before((1, 15)):
2617
return self._vfs_set_parent_location(url)
2619
call_url = url or ''
2620
if type(call_url) is not str:
2621
raise AssertionError('url must be a str or None (%s)' % url)
2622
response = self._call('Branch.set_parent_location',
2623
self._remote_path(), self._lock_token, self._repo_lock_token,
2625
except errors.UnknownSmartMethod:
2626
medium._remember_remote_is_before((1, 15))
2627
return self._vfs_set_parent_location(url)
2629
raise errors.UnexpectedSmartServerResponse(response)
2631
def _vfs_set_parent_location(self, url):
2300
2632
self._ensure_real()
2301
return self._real_branch.set_stacked_on_url(stacked_location)
2633
return self._real_branch._set_parent_location(url)
2303
2635
@needs_write_lock
2304
2636
def pull(self, source, overwrite=False, stop_revision=None,
2372
2704
return self._real_branch.set_push_location(location)
2707
class RemoteConfig(object):
2708
"""A Config that reads and writes from smart verbs.
2710
It is a low-level object that considers config data to be name/value pairs
2711
that may be associated with a section. Assigning meaning to the these
2712
values is done at higher levels like bzrlib.config.TreeConfig.
2715
def get_option(self, name, section=None, default=None):
2716
"""Return the value associated with a named option.
2718
:param name: The name of the value
2719
:param section: The section the option is in (if any)
2720
:param default: The value to return if the value is not set
2721
:return: The value or default value
2724
configobj = self._get_configobj()
2726
section_obj = configobj
2729
section_obj = configobj[section]
2732
return section_obj.get(name, default)
2733
except errors.UnknownSmartMethod:
2734
return self._vfs_get_option(name, section, default)
2736
def _response_to_configobj(self, response):
2737
if len(response[0]) and response[0][0] != 'ok':
2738
raise errors.UnexpectedSmartServerResponse(response)
2739
lines = response[1].read_body_bytes().splitlines()
2740
return config.ConfigObj(lines, encoding='utf-8')
2743
class RemoteBranchConfig(RemoteConfig):
2744
"""A RemoteConfig for Branches."""
2746
def __init__(self, branch):
2747
self._branch = branch
2749
def _get_configobj(self):
2750
path = self._branch._remote_path()
2751
response = self._branch._client.call_expecting_body(
2752
'Branch.get_config_file', path)
2753
return self._response_to_configobj(response)
2755
def set_option(self, value, name, section=None):
2756
"""Set the value associated with a named option.
2758
:param value: The value to set
2759
:param name: The name of the value to set
2760
:param section: The section the option is in (if any)
2762
medium = self._branch._client._medium
2763
if medium._is_remote_before((1, 14)):
2764
return self._vfs_set_option(value, name, section)
2766
path = self._branch._remote_path()
2767
response = self._branch._client.call('Branch.set_config_option',
2768
path, self._branch._lock_token, self._branch._repo_lock_token,
2769
value.encode('utf8'), name, section or '')
2770
except errors.UnknownSmartMethod:
2771
medium._remember_remote_is_before((1, 14))
2772
return self._vfs_set_option(value, name, section)
2774
raise errors.UnexpectedSmartServerResponse(response)
2776
def _real_object(self):
2777
self._branch._ensure_real()
2778
return self._branch._real_branch
2780
def _vfs_set_option(self, value, name, section=None):
2781
return self._real_object()._get_config().set_option(
2782
value, name, section)
2785
class RemoteBzrDirConfig(RemoteConfig):
2786
"""A RemoteConfig for BzrDirs."""
2788
def __init__(self, bzrdir):
2789
self._bzrdir = bzrdir
2791
def _get_configobj(self):
2792
medium = self._bzrdir._client._medium
2793
verb = 'BzrDir.get_config_file'
2794
if medium._is_remote_before((1, 15)):
2795
raise errors.UnknownSmartMethod(verb)
2796
path = self._bzrdir._path_for_remote_call(self._bzrdir._client)
2797
response = self._bzrdir._call_expecting_body(
2799
return self._response_to_configobj(response)
2801
def _vfs_get_option(self, name, section, default):
2802
return self._real_object()._get_config().get_option(
2803
name, section, default)
2805
def set_option(self, value, name, section=None):
2806
"""Set the value associated with a named option.
2808
:param value: The value to set
2809
:param name: The name of the value to set
2810
:param section: The section the option is in (if any)
2812
return self._real_object()._get_config().set_option(
2813
value, name, section)
2815
def _real_object(self):
2816
self._bzrdir._ensure_real()
2817
return self._bzrdir._real_bzrdir
2375
2821
def _extract_tar(tar, to_dir):
2376
2822
"""Extract all the contents of a tarfile object.
2415
2861
'Missing key %r in context %r', key_err.args[0], context)
2418
if err.error_verb == 'NoSuchRevision':
2864
if err.error_verb == 'IncompatibleRepositories':
2865
raise errors.IncompatibleRepositories(err.error_args[0],
2866
err.error_args[1], err.error_args[2])
2867
elif err.error_verb == 'NoSuchRevision':
2419
2868
raise NoSuchRevision(find('branch'), err.error_args[0])
2420
2869
elif err.error_verb == 'nosuchrevision':
2421
2870
raise NoSuchRevision(find('repository'), err.error_args[0])
2422
elif err.error_tuple == ('nobranch',):
2423
raise errors.NotBranchError(path=find('bzrdir').root_transport.base)
2871
elif err.error_verb == 'nobranch':
2872
if len(err.error_args) >= 1:
2873
extra = err.error_args[0]
2876
raise errors.NotBranchError(path=find('bzrdir').root_transport.base,
2424
2878
elif err.error_verb == 'norepository':
2425
2879
raise errors.NoRepositoryPresent(find('bzrdir'))
2426
2880
elif err.error_verb == 'LockContention':