1
# Copyright (C) 2006-2011 Canonical Ltd
1
# Copyright (C) 2006-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
33
33
revision as _mod_revision,
38
37
from bzrlib.branch import BranchReferenceFormat, BranchWriteLockResult
39
38
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
247
246
self._ensure_real()
248
247
self._real_bzrdir.destroy_repository()
250
def create_branch(self, name=None, repository=None):
249
def create_branch(self, name=None):
251
250
# as per meta1 formats - just delegate to the format object which may
252
251
# be parameterised.
253
252
real_branch = self._format.get_branch_format().initialize(self,
254
name=name, repository=repository)
255
254
if not isinstance(real_branch, RemoteBranch):
256
if not isinstance(repository, RemoteRepository):
257
raise AssertionError(
258
'need a RemoteRepository to use with RemoteBranch, got %r'
260
result = RemoteBranch(self, repository, real_branch, name=name)
255
result = RemoteBranch(self, self.find_repository(), real_branch,
262
258
result = real_branch
263
259
# BzrDir.clone_on_transport() uses the result of create_branch but does
1350
1346
@needs_read_lock
1351
def search_missing_revision_ids(self, other,
1352
revision_id=symbol_versioning.DEPRECATED_PARAMETER,
1353
find_ghosts=True, revision_ids=None, if_present_ids=None):
1347
def search_missing_revision_ids(self, other, revision_id=None, find_ghosts=True):
1354
1348
"""Return the revision ids that other has that this does not.
1356
1350
These are returned in topological order.
1358
1352
revision_id: only return revision ids included by revision_id.
1360
if symbol_versioning.deprecated_passed(revision_id):
1361
symbol_versioning.warn(
1362
'search_missing_revision_ids(revision_id=...) was '
1363
'deprecated in 2.4. Use revision_ids=[...] instead.',
1364
DeprecationWarning, stacklevel=2)
1365
if revision_ids is not None:
1366
raise AssertionError(
1367
'revision_ids is mutually exclusive with revision_id')
1368
if revision_id is not None:
1369
revision_ids = [revision_id]
1370
inter_repo = repository.InterRepository.get(other, self)
1371
return inter_repo.search_missing_revision_ids(
1372
find_ghosts=find_ghosts, revision_ids=revision_ids,
1373
if_present_ids=if_present_ids)
1354
return repository.InterRepository.get(
1355
other, self).search_missing_revision_ids(revision_id, find_ghosts)
1375
1357
def fetch(self, source, revision_id=None, pb=None, find_ghosts=False,
1376
1358
fetch_spec=None):
1777
1759
return '\n'.join((start_keys, stop_keys, count))
1779
1761
def _serialise_search_result(self, search_result):
1780
parts = search_result.get_network_struct()
1762
if isinstance(search_result, graph.PendingAncestryResult):
1763
parts = ['ancestry-of']
1764
parts.extend(search_result.heads)
1766
recipe = search_result.get_recipe()
1767
parts = [recipe[0], self._serialise_search_recipe(recipe)]
1781
1768
return '\n'.join(parts)
1783
1770
def autopack(self):
1977
1964
candidate_verbs = [
1978
1965
('Repository.get_stream_1.19', (1, 19)),
1979
1966
('Repository.get_stream', (1, 13))]
1981
1967
found_verb = False
1982
1968
for verb, version in candidate_verbs:
1983
1969
if medium._is_remote_before(version):
1987
1973
verb, args, search_bytes)
1988
1974
except errors.UnknownSmartMethod:
1989
1975
medium._remember_remote_is_before(version)
1990
except errors.UnknownErrorFromSmartServer, e:
1991
if isinstance(search, graph.EverythingResult):
1992
error_verb = e.error_from_smart_server.error_verb
1993
if error_verb == 'BadSearch':
1994
# Pre-2.4 servers don't support this sort of search.
1995
# XXX: perhaps falling back to VFS on BadSearch is a
1996
# good idea in general? It might provide a little bit
1997
# of protection against client-side bugs.
1998
medium._remember_remote_is_before((2, 4))
2002
1977
response_tuple, response_handler = response
2003
1978
found_verb = True
2121
def initialize(self, a_bzrdir, name=None, repository=None):
2096
def initialize(self, a_bzrdir, name=None):
2122
2097
# 1) get the network name to use.
2123
2098
if self._custom_format:
2124
2099
network_name = self._custom_format.network_name()
2152
2127
# Turn the response into a RemoteRepository object.
2153
2128
format = RemoteBranchFormat(network_name=response[1])
2154
2129
repo_format = response_tuple_to_repo_format(response[3:])
2155
repo_path = response[2]
2156
if repository is not None:
2157
remote_repo_url = urlutils.join(medium.base, repo_path)
2158
url_diff = urlutils.relative_url(repository.user_url,
2161
raise AssertionError(
2162
'repository.user_url %r does not match URL from server '
2163
'response (%r + %r)'
2164
% (repository.user_url, medium.base, repo_path))
2165
remote_repo = repository
2130
if response[2] == '':
2131
repo_bzrdir = a_bzrdir
2168
repo_bzrdir = a_bzrdir
2170
repo_bzrdir = RemoteBzrDir(
2171
a_bzrdir.root_transport.clone(repo_path), a_bzrdir._format,
2173
remote_repo = RemoteRepository(repo_bzrdir, repo_format)
2133
repo_bzrdir = RemoteBzrDir(
2134
a_bzrdir.root_transport.clone(response[2]), a_bzrdir._format,
2136
remote_repo = RemoteRepository(repo_bzrdir, repo_format)
2174
2137
remote_branch = RemoteBranch(a_bzrdir, remote_repo,
2175
2138
format=format, setup_stacking=False, name=name)
2176
2139
# XXX: We know this is a new branch, so it must have revno 0, revid
2406
2369
self._ensure_real()
2407
2370
return self._real_branch._get_tags_bytes()
2410
2372
def _get_tags_bytes(self):
2411
if self._tags_bytes is None:
2412
self._tags_bytes = self._get_tags_bytes_via_hpss()
2413
return self._tags_bytes
2415
def _get_tags_bytes_via_hpss(self):
2416
2373
medium = self._client._medium
2417
2374
if medium._is_remote_before((1, 13)):
2418
2375
return self._vfs_get_tags_bytes()
2428
2385
return self._real_branch._set_tags_bytes(bytes)
2430
2387
def _set_tags_bytes(self, bytes):
2431
if self.is_locked():
2432
self._tags_bytes = bytes
2433
2388
medium = self._client._medium
2434
2389
if medium._is_remote_before((1, 18)):
2435
2390
self._vfs_set_tags_bytes(bytes)