31
31
from bzrlib.decorators import needs_read_lock, needs_write_lock
32
32
from bzrlib.errors import NoSuchRevision
33
33
from bzrlib.lockable_files import LockableFiles
34
from bzrlib.pack import ContainerReader
34
35
from bzrlib.revision import NULL_REVISION
35
36
from bzrlib.smart import client, vfs
36
37
from bzrlib.symbol_versioning import (
345
347
def get_graph(self, other_repository=None):
346
348
"""Return the graph for this repository format"""
347
350
return self._real_repository.get_graph(other_repository)
349
352
def gather_stats(self, revid=None, committers=None):
398
401
assert response[0] in ('yes', 'no'), 'unexpected response code %s' % (response,)
399
402
return response[0] == 'yes'
404
def is_write_locked(self):
405
return self._lock_mode == 'w'
401
407
def lock_read(self):
402
408
# wrong eventually - want a local lock cache context
403
409
if not self._lock_mode:
539
545
def sprout(self, to_bzrdir, revision_id=None):
540
546
# TODO: Option to control what format is created?
541
to_repo = self._copy_repository_tarball(to_bzrdir, revision_id)
544
return self._real_repository.sprout(
545
to_bzrdir, revision_id=revision_id)
547
dest_repo = to_bzrdir.create_repository()
548
dest_repo.fetch(self, revision_id=revision_id)
549
551
### These methods are just thin shims to the VFS object for now.
643
645
self._ensure_real()
644
646
return self._real_repository.fileids_altered_by_revision_ids(revision_ids)
648
def get_versioned_file_checker(self, revisions, revision_versions_cache):
650
return self._real_repository.get_versioned_file_checker(
651
revisions, revision_versions_cache)
646
653
def iter_files_bytes(self, desired_files):
647
654
"""See Repository.iter_file_bytes.
698
705
return self._real_repository.get_revision_reconcile(revision_id)
701
def check(self, revision_ids):
708
def check(self, revision_ids=None):
702
709
self._ensure_real()
703
return self._real_repository.check(revision_ids)
710
return self._real_repository.check(revision_ids=revision_ids)
705
712
def copy_content_into(self, destination, revision_id=None):
706
713
self._ensure_real()
781
788
self._ensure_real()
782
789
return self._real_repository.has_signature_for_revision_id(revision_id)
791
def get_data_stream(self, revision_ids):
792
path = self.bzrdir._path_for_remote_call(self._client)
793
response, protocol = self._client.call_expecting_body(
794
'Repository.stream_knit_data_for_revisions', path, *revision_ids)
795
if response == ('ok',):
796
return self._deserialise_stream(protocol)
797
elif (response == ('error', "Generic bzr smart protocol error: "
798
"bad request 'Repository.stream_knit_data_for_revisions'") or
799
response == ('error', "Generic bzr smart protocol error: "
800
"bad request u'Repository.stream_knit_data_for_revisions'")):
801
protocol.cancel_read_body()
803
return self._real_repository.get_data_stream(revision_ids)
805
raise errors.UnexpectedSmartServerResponse(response)
807
def _deserialise_stream(self, protocol):
808
buffer = StringIO(protocol.read_body_bytes())
809
reader = ContainerReader(buffer)
810
for record_names, read_bytes in reader.iter_records():
812
# These records should have only one name, and that name
813
# should be a one-element tuple.
814
[name_tuple] = record_names
816
raise errors.SmartProtocolError(
817
'Repository data stream had invalid record name %r'
819
yield name_tuple, read_bytes(None)
821
def insert_data_stream(self, stream):
823
self._real_repository.insert_data_stream(stream)
825
def item_keys_introduced_by(self, revision_ids, _files_pb=None):
827
return self._real_repository.item_keys_introduced_by(revision_ids,
830
def revision_graph_can_have_wrong_parents(self):
831
# The answer depends on the remote repo format.
833
return self._real_repository.revision_graph_can_have_wrong_parents()
835
def _find_inconsistent_revision_parents(self):
837
return self._real_repository._find_inconsistent_revision_parents()
839
def _check_for_inconsistent_revision_parents(self):
841
return self._real_repository._check_for_inconsistent_revision_parents()
785
844
class RemoteBranchLockableFiles(LockableFiles):
786
845
"""A 'LockableFiles' implementation that talks to a smart server.