~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert Collins
  • Date: 2007-10-17 09:39:41 UTC
  • mfrom: (2911 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071017093941-v7d1djrt2617citb
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 (
259
260
        self._leave_lock = False
260
261
        # for tests
261
262
        self._reconcile_does_inventory_gc = True
 
263
        self._reconcile_fixes_text_parents = True
262
264
        self.base = self.bzrdir.transport.base
263
265
 
264
266
    def __str__(self):
344
346
        
345
347
    def get_graph(self, other_repository=None):
346
348
        """Return the graph for this repository format"""
 
349
        self._ensure_real()
347
350
        return self._real_repository.get_graph(other_repository)
348
351
 
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'
400
403
 
 
404
    def is_write_locked(self):
 
405
        return self._lock_mode == 'w'
 
406
 
401
407
    def lock_read(self):
402
408
        # wrong eventually - want a local lock cache context
403
409
        if not self._lock_mode:
538
544
 
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)
542
 
        if to_repo is None:
543
 
            self._ensure_real()
544
 
            return self._real_repository.sprout(
545
 
                to_bzrdir, revision_id=revision_id)
546
 
        else:
547
 
            return to_repo
 
547
        dest_repo = to_bzrdir.create_repository()
 
548
        dest_repo.fetch(self, revision_id=revision_id)
 
549
        return dest_repo
548
550
 
549
551
    ### These methods are just thin shims to the VFS object for now.
550
552
 
643
645
        self._ensure_real()
644
646
        return self._real_repository.fileids_altered_by_revision_ids(revision_ids)
645
647
 
 
648
    def get_versioned_file_checker(self, revisions, revision_versions_cache):
 
649
        self._ensure_real()
 
650
        return self._real_repository.get_versioned_file_checker(
 
651
            revisions, revision_versions_cache)
 
652
        
646
653
    def iter_files_bytes(self, desired_files):
647
654
        """See Repository.iter_file_bytes.
648
655
        """
698
705
        return self._real_repository.get_revision_reconcile(revision_id)
699
706
 
700
707
    @needs_read_lock
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)
704
711
 
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)
783
790
 
 
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()
 
802
            self._ensure_real()
 
803
            return self._real_repository.get_data_stream(revision_ids)
 
804
        else:
 
805
            raise errors.UnexpectedSmartServerResponse(response)
 
806
 
 
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():
 
811
            try:
 
812
                # These records should have only one name, and that name
 
813
                # should be a one-element tuple.
 
814
                [name_tuple] = record_names
 
815
            except ValueError:
 
816
                raise errors.SmartProtocolError(
 
817
                    'Repository data stream had invalid record name %r'
 
818
                    % (record_names,))
 
819
            yield name_tuple, read_bytes(None)
 
820
 
 
821
    def insert_data_stream(self, stream):
 
822
        self._ensure_real()
 
823
        self._real_repository.insert_data_stream(stream)
 
824
 
 
825
    def item_keys_introduced_by(self, revision_ids, _files_pb=None):
 
826
        self._ensure_real()
 
827
        return self._real_repository.item_keys_introduced_by(revision_ids,
 
828
            _files_pb=_files_pb)
 
829
 
 
830
    def revision_graph_can_have_wrong_parents(self):
 
831
        # The answer depends on the remote repo format.
 
832
        self._ensure_real()
 
833
        return self._real_repository.revision_graph_can_have_wrong_parents()
 
834
 
 
835
    def _find_inconsistent_revision_parents(self):
 
836
        self._ensure_real()
 
837
        return self._real_repository._find_inconsistent_revision_parents()
 
838
 
 
839
    def _check_for_inconsistent_revision_parents(self):
 
840
        self._ensure_real()
 
841
        return self._real_repository._check_for_inconsistent_revision_parents()
 
842
 
784
843
 
785
844
class RemoteBranchLockableFiles(LockableFiles):
786
845
    """A 'LockableFiles' implementation that talks to a smart server.