/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-18 01:16:25 UTC
  • mfrom: (3184.1.13 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080118011625-465mgy0mhdz1jiky
(robertc) Reduce traffic when requesting revision streams from a
        smart server (3 MB to 172 bytes for a full bzr.dev pull)
        (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
691
691
        """RemoteRepositories never create working trees by default."""
692
692
        return False
693
693
 
 
694
    def revision_ids_to_search_result(self, result_set):
 
695
        """Convert a set of revision ids to a graph SearchResult."""
 
696
        result_parents = set()
 
697
        for parents in self.get_graph().get_parent_map(
 
698
            result_set).itervalues():
 
699
            result_parents.update(parents)
 
700
        included_keys = result_set.intersection(result_parents)
 
701
        start_keys = result_set.difference(included_keys)
 
702
        exclude_keys = result_parents.difference(result_set)
 
703
        result = graph.SearchResult(start_keys, exclude_keys,
 
704
            len(result_set), result_set)
 
705
        return result
 
706
 
 
707
    @needs_read_lock
 
708
    def search_missing_revision_ids(self, other, revision_id=None, find_ghosts=True):
 
709
        """Return the revision ids that other has that this does not.
 
710
        
 
711
        These are returned in topological order.
 
712
 
 
713
        revision_id: only return revision ids included by revision_id.
 
714
        """
 
715
        return repository.InterRepository.get(
 
716
            other, self).search_missing_revision_ids(revision_id, find_ghosts)
 
717
 
694
718
    def fetch(self, source, revision_id=None, pb=None):
695
719
        if self.has_same_location(source):
696
720
            # check that last_revision is in 'from' and then return a
941
965
        self._ensure_real()
942
966
        return self._real_repository.has_signature_for_revision_id(revision_id)
943
967
 
944
 
    def get_data_stream(self, revision_ids):
 
968
    def get_data_stream_for_search(self, search):
945
969
        REQUEST_NAME = 'Repository.stream_revisions_chunked'
946
970
        path = self.bzrdir._path_for_remote_call(self._client)
947
 
        response, protocol = self._client.call_expecting_body(
948
 
            REQUEST_NAME, path, *revision_ids)
 
971
        recipe = search.get_recipe()
 
972
        start_keys = ' '.join(recipe[0])
 
973
        stop_keys = ' '.join(recipe[1])
 
974
        count = str(recipe[2])
 
975
        body = '\n'.join((start_keys, stop_keys, count))
 
976
        response, protocol = self._client.call_with_body_bytes_expecting_body(
 
977
            REQUEST_NAME, (path,), body)
949
978
 
950
979
        if response == ('ok',):
951
980
            return self._deserialise_stream(protocol)
 
981
        if response == ('NoSuchRevision', ):
 
982
            # We cannot easily identify the revision that is missing in this
 
983
            # situation without doing much more network IO. For now, bail.
 
984
            raise NoSuchRevision(self, "unknown")
952
985
        elif (response == ('error', "Generic bzr smart protocol error: "
953
986
                "bad request '%s'" % REQUEST_NAME) or
954
987
              response == ('error', "Generic bzr smart protocol error: "
955
988
                "bad request u'%s'" % REQUEST_NAME)):
956
989
            protocol.cancel_read_body()
957
990
            self._ensure_real()
958
 
            return self._real_repository.get_data_stream(revision_ids)
 
991
            return self._real_repository.get_data_stream_for_search(search)
959
992
        else:
960
993
            raise errors.UnexpectedSmartServerResponse(response)
961
994