41
41
SmartProtocolError,
43
43
from bzrlib.i18n import gettext
44
from bzrlib.inventory import Inventory
44
45
from bzrlib.lockable_files import LockableFiles
45
46
from bzrlib.smart import client, vfs, repository as smart_repo
46
47
from bzrlib.smart.client import _SmartClient
47
48
from bzrlib.revision import NULL_REVISION
49
from bzrlib.revisiontree import InventoryRevisionTree
48
50
from bzrlib.repository import RepositoryWriteLockResult, _LazyListJoin
49
51
from bzrlib.trace import mutter, note, warning
698
700
"""Upgrading of remote bzrdirs is not supported yet."""
701
def clone(self, url, revision_id=None, force_new_repo=False,
702
preserve_stacking=False):
704
return self._real_bzrdir.clone(url, revision_id=revision_id,
705
force_new_repo=force_new_repo, preserve_stacking=preserve_stacking)
707
703
def _get_config(self):
708
704
return RemoteBzrDirConfig(self)
1480
1476
raise errors.UnexpectedSmartServerResponse(response)
1482
1479
def sprout(self, to_bzrdir, revision_id=None):
1483
# TODO: Option to control what format is created?
1485
dest_repo = self._real_repository._format.initialize(to_bzrdir,
1480
"""Create a descendent repository for new development.
1482
Unlike clone, this does not copy the settings of the repository.
1484
dest_repo = self._create_sprouting_repo(to_bzrdir, shared=False)
1487
1485
dest_repo.fetch(self, revision_id=revision_id)
1488
1486
return dest_repo
1488
def _create_sprouting_repo(self, a_bzrdir, shared):
1489
if not isinstance(a_bzrdir._format, self.bzrdir._format.__class__):
1490
# use target default format.
1491
dest_repo = a_bzrdir.create_repository()
1493
# Most control formats need the repository to be specifically
1494
# created, but on some old all-in-one formats it's not needed
1496
dest_repo = self._format.initialize(a_bzrdir, shared=shared)
1497
except errors.UninitializableFormat:
1498
dest_repo = a_bzrdir.open_repository()
1490
1501
### These methods are just thin shims to the VFS object for now.
1492
1504
def revision_tree(self, revision_id):
1494
return self._real_repository.revision_tree(revision_id)
1505
revision_id = _mod_revision.ensure_null(revision_id)
1506
if revision_id == _mod_revision.NULL_REVISION:
1507
return InventoryRevisionTree(self,
1508
Inventory(root_id=None), _mod_revision.NULL_REVISION)
1510
return list(self.revision_trees([revision_id]))[0]
1496
1512
def get_serializer_format(self):
1497
1513
self._ensure_real()
1576
1592
@needs_read_lock
1577
1593
def get_revision(self, revision_id):
1579
return self._real_repository.get_revision(revision_id)
1594
return self.get_revisions([revision_id])[0]
1581
1596
def get_transaction(self):
1582
1597
self._ensure_real()
1585
1600
@needs_read_lock
1586
1601
def clone(self, a_bzrdir, revision_id=None):
1588
return self._real_repository.clone(a_bzrdir, revision_id=revision_id)
1602
dest_repo = self._create_sprouting_repo(
1603
a_bzrdir, shared=self.is_shared())
1604
self.copy_content_into(dest_repo, revision_id)
1590
1607
def make_working_trees(self):
1591
1608
"""See Repository.make_working_trees"""
1593
return self._real_repository.make_working_trees()
1609
path = self.bzrdir._path_for_remote_call(self._client)
1611
response = self._call('Repository.make_working_trees', path)
1612
except errors.UnknownSmartMethod:
1614
return self._real_repository.make_working_trees()
1615
if response[0] not in ('yes', 'no'):
1616
raise SmartProtocolError('unexpected response code %s' % (response,))
1617
return response[0] == 'yes'
1595
1619
def refresh_data(self):
1596
1620
"""Re-read any data needed to synchronise with disk.
1853
1877
@needs_read_lock
1854
1878
def get_revision_delta(self, revision_id, specific_fileids=None):
1856
return self._real_repository.get_revision_delta(revision_id,
1857
specific_fileids=specific_fileids)
1879
r = self.get_revision(revision_id)
1880
return list(self.get_deltas_for_revisions([r],
1881
specific_fileids=specific_fileids))[0]
1859
1883
@needs_read_lock
1860
1884
def revision_trees(self, revision_ids):
1873
1897
callback_refs=callback_refs, check_repo=check_repo)
1875
1899
def copy_content_into(self, destination, revision_id=None):
1877
return self._real_repository.copy_content_into(
1878
destination, revision_id=revision_id)
1900
"""Make a complete copy of the content in self into destination.
1902
This is a destructive operation! Do not use it on existing
1905
interrepo = _mod_repository.InterRepository.get(self, destination)
1906
return interrepo.copy_content(revision_id)
1880
1908
def _copy_repository_tarball(self, to_bzrdir, revision_id=None):
1881
1909
# get a tarball of the remote repository, and copy from that into the
1994
2022
def _serializer(self):
1995
2023
return self._format._serializer
1997
2026
def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
1999
return self._real_repository.store_revision_signature(
2000
gpg_strategy, plaintext, revision_id)
2027
signature = gpg_strategy.sign(plaintext)
2028
self.add_signature_text(revision_id, signature)
2002
2030
def add_signature_text(self, revision_id, signature):
2003
2031
self._ensure_real()
2004
2032
return self._real_repository.add_signature_text(revision_id, signature)
2006
2034
def has_signature_for_revision_id(self, revision_id):
2035
path = self.bzrdir._path_for_remote_call(self._client)
2037
response = self._call('Repository.has_signature_for_revision_id',
2039
except errors.UnknownSmartMethod:
2041
return self._real_repository.has_signature_for_revision_id(
2043
if response[0] not in ('yes', 'no'):
2044
raise SmartProtocolError('unexpected response code %s' % (response,))
2045
return (response[0] == 'yes')
2047
def verify_revision_signature(self, revision_id, gpg_strategy):
2007
2048
self._ensure_real()
2008
return self._real_repository.has_signature_for_revision_id(revision_id)
2049
return self._real_repository.verify_revision_signature(
2050
revision_id, gpg_strategy)
2010
2052
def item_keys_introduced_by(self, revision_ids, _files_pb=None):
2011
2053
self._ensure_real()