242
242
self._ensure_real()
243
243
self._real_bzrdir.destroy_repository()
245
def create_branch(self, name=None):
245
def create_branch(self):
246
246
# as per meta1 formats - just delegate to the format object which may
247
247
# be parameterised.
248
real_branch = self._format.get_branch_format().initialize(self,
248
real_branch = self._format.get_branch_format().initialize(self)
250
249
if not isinstance(real_branch, RemoteBranch):
251
result = RemoteBranch(self, self.find_repository(), real_branch,
250
result = RemoteBranch(self, self.find_repository(), real_branch)
254
252
result = real_branch
255
253
# BzrDir.clone_on_transport() uses the result of create_branch but does
261
259
self._next_open_branch_result = result
264
def destroy_branch(self, name=None):
262
def destroy_branch(self):
265
263
"""See BzrDir.destroy_branch"""
266
264
self._ensure_real()
267
self._real_bzrdir.destroy_branch(name=name)
265
self._real_bzrdir.destroy_branch()
268
266
self._next_open_branch_result = None
270
268
def create_workingtree(self, revision_id=None, from_branch=None):
320
318
"""See BzrDir._get_tree_branch()."""
321
319
return None, self.open_branch()
323
def open_branch(self, name=None, unsupported=False,
324
ignore_fallbacks=False):
321
def open_branch(self, _unsupported=False, ignore_fallbacks=False):
326
323
raise NotImplementedError('unsupported flag support not implemented yet.')
327
324
if self._next_open_branch_result is not None:
328
325
# See create_branch for details.
333
330
if response[0] == 'ref':
334
331
# a branch reference, use the existing BranchReference logic.
335
332
format = BranchReferenceFormat()
336
return format.open(self, name=name, _found=True,
337
location=response[1], ignore_fallbacks=ignore_fallbacks)
333
return format.open(self, _found=True, location=response[1],
334
ignore_fallbacks=ignore_fallbacks)
338
335
branch_format_name = response[1]
339
336
if not branch_format_name:
340
337
branch_format_name = None
341
338
format = RemoteBranchFormat(network_name=branch_format_name)
342
339
return RemoteBranch(self, self.find_repository(), format=format,
343
setup_stacking=not ignore_fallbacks, name=name)
340
setup_stacking=not ignore_fallbacks)
345
342
def _open_repo_v1(self, path):
346
343
verb = 'BzrDir.find_repository'
423
420
"""Return the path to be used for this bzrdir in a remote call."""
424
421
return client.remote_path_from_transport(self.root_transport)
426
def get_branch_transport(self, branch_format, name=None):
423
def get_branch_transport(self, branch_format):
427
424
self._ensure_real()
428
return self._real_bzrdir.get_branch_transport(branch_format, name=name)
425
return self._real_bzrdir.get_branch_transport(branch_format)
430
427
def get_repository_transport(self, repository_format):
431
428
self._ensure_real()
1232
1229
return self._real_repository.add_inventory(revid, inv, parents)
1234
1231
def add_inventory_by_delta(self, basis_revision_id, delta, new_revision_id,
1235
parents, basis_inv=None, propagate_caches=False):
1236
1233
self._ensure_real()
1237
1234
return self._real_repository.add_inventory_by_delta(basis_revision_id,
1238
delta, new_revision_id, parents, basis_inv=basis_inv,
1239
propagate_caches=propagate_caches)
1235
delta, new_revision_id, parents)
1241
1237
def add_revision(self, rev_id, rev, inv=None, config=None):
1242
1238
self._ensure_real()
2025
2021
def network_name(self):
2026
2022
return self._network_name
2028
def open(self, a_bzrdir, name=None, ignore_fallbacks=False):
2029
return a_bzrdir.open_branch(name=name,
2030
ignore_fallbacks=ignore_fallbacks)
2024
def open(self, a_bzrdir, ignore_fallbacks=False):
2025
return a_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks)
2032
def _vfs_initialize(self, a_bzrdir, name):
2027
def _vfs_initialize(self, a_bzrdir):
2033
2028
# Initialisation when using a local bzrdir object, or a non-vfs init
2034
2029
# method is not available on the server.
2035
2030
# self._custom_format is always set - the start of initialize ensures
2037
2032
if isinstance(a_bzrdir, RemoteBzrDir):
2038
2033
a_bzrdir._ensure_real()
2039
result = self._custom_format.initialize(a_bzrdir._real_bzrdir,
2034
result = self._custom_format.initialize(a_bzrdir._real_bzrdir)
2042
2036
# We assume the bzrdir is parameterised; it may not be.
2043
result = self._custom_format.initialize(a_bzrdir, name)
2037
result = self._custom_format.initialize(a_bzrdir)
2044
2038
if (isinstance(a_bzrdir, RemoteBzrDir) and
2045
2039
not isinstance(result, RemoteBranch)):
2046
result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result,
2040
result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result)
2050
def initialize(self, a_bzrdir, name=None):
2043
def initialize(self, a_bzrdir):
2051
2044
# 1) get the network name to use.
2052
2045
if self._custom_format:
2053
2046
network_name = self._custom_format.network_name()
2059
2052
network_name = reference_format.network_name()
2060
2053
# Being asked to create on a non RemoteBzrDir:
2061
2054
if not isinstance(a_bzrdir, RemoteBzrDir):
2062
return self._vfs_initialize(a_bzrdir, name=name)
2055
return self._vfs_initialize(a_bzrdir)
2063
2056
medium = a_bzrdir._client._medium
2064
2057
if medium._is_remote_before((1, 13)):
2065
return self._vfs_initialize(a_bzrdir, name=name)
2058
return self._vfs_initialize(a_bzrdir)
2066
2059
# Creating on a remote bzr dir.
2067
2060
# 2) try direct creation via RPC
2068
2061
path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
2069
if name is not None:
2070
# XXX JRV20100304: Support creating colocated branches
2071
raise errors.NoColocatedBranchSupport(self)
2072
2062
verb = 'BzrDir.create_branch'
2074
2064
response = a_bzrdir._call(verb, path, network_name)
2075
2065
except errors.UnknownSmartMethod:
2076
2066
# Fallback - use vfs methods
2077
2067
medium._remember_remote_is_before((1, 13))
2078
return self._vfs_initialize(a_bzrdir, name=name)
2068
return self._vfs_initialize(a_bzrdir)
2079
2069
if response[0] != 'ok':
2080
2070
raise errors.UnexpectedSmartServerResponse(response)
2081
2071
# Turn the response into a RemoteRepository object.
2089
2079
a_bzrdir._client)
2090
2080
remote_repo = RemoteRepository(repo_bzrdir, repo_format)
2091
2081
remote_branch = RemoteBranch(a_bzrdir, remote_repo,
2092
format=format, setup_stacking=False, name=name)
2082
format=format, setup_stacking=False)
2093
2083
# XXX: We know this is a new branch, so it must have revno 0, revid
2094
2084
# NULL_REVISION. Creating the branch locked would make this be unable
2095
2085
# to be wrong; here its simply very unlikely to be wrong. RBC 20090225
2124
2114
def __init__(self, remote_bzrdir, remote_repository, real_branch=None,
2125
_client=None, format=None, setup_stacking=True, name=None):
2115
_client=None, format=None, setup_stacking=True):
2126
2116
"""Create a RemoteBranch instance.
2128
2118
:param real_branch: An optional local implementation of the branch
2134
2124
:param setup_stacking: If True make an RPC call to determine the
2135
2125
stacked (or not) status of the branch. If False assume the branch
2136
2126
is not stacked.
2137
:param name: Colocated branch name
2139
2128
# We intentionally don't call the parent class's __init__, because it
2140
2129
# will try to assign to self.tags, which is a property in this subclass.
2231
2219
'to use vfs implementation')
2232
2220
self.bzrdir._ensure_real()
2233
2221
self._real_branch = self.bzrdir._real_bzrdir.open_branch(
2234
ignore_fallbacks=self._real_ignore_fallbacks, name=self._name)
2222
ignore_fallbacks=self._real_ignore_fallbacks)
2235
2223
if self.repository._real_repository is None:
2236
2224
# Give the remote repository the matching real repo.
2237
2225
real_repo = self._real_branch.repository