795
795
def _get_parent_map(self, keys):
796
796
"""Helper for get_parent_map that performs the RPC."""
797
medium = self._client.get_smart_medium()
798
if not medium._remote_is_at_least_1_2:
799
# We already found out that the server can't understand
800
# Repository.get_revision_graph requests, so just fetch the whole
802
return self.get_revision_graph()
798
805
if NULL_REVISION in keys:
799
806
keys.discard(NULL_REVISION)
810
817
verb, path, *keys)
811
818
if self._response_is_unknown_method(response, verb):
812
819
# Server that does not support this method, get the whole graph.
813
response = self._client.call_expecting_body(
814
'Repository.get_revision_graph', path, '')
815
if response[0][0] not in ['ok', 'nosuchrevision']:
816
reponse[1].cancel_read_body()
817
raise errors.UnexpectedSmartServerResponse(response[0])
820
# Worse, we have to force a disconnection, because the server now
821
# doesn't realise it has a body on the wire to consume, so the
822
# only way to recover is to abandon the connection.
824
# To avoid having to disconnect repeatedly, we keep track of the
825
# fact the server doesn't understand remote methods added in 1.2.
826
medium._remote_is_at_least_1_2 = False
827
return self.get_revision_graph()
818
828
elif response[0][0] not in ['ok']:
819
829
reponse[1].cancel_read_body()
820
830
raise errors.UnexpectedSmartServerResponse(response[0])
970
980
return self._real_repository.has_signature_for_revision_id(revision_id)
972
982
def get_data_stream_for_search(self, search):
983
medium = self._client.get_smart_medium()
984
if not medium._remote_is_at_least_1_2:
986
return self._real_repository.get_data_stream_for_search(search)
973
987
REQUEST_NAME = 'Repository.stream_revisions_chunked'
974
988
path = self.bzrdir._path_for_remote_call(self._client)
975
989
recipe = search.get_recipe()
980
994
response, protocol = self._client.call_with_body_bytes_expecting_body(
981
995
REQUEST_NAME, (path,), body)
997
if self._response_is_unknown_method((response, protocol), REQUEST_NAME):
998
# Server that does not support this method, fall back to VFS.
999
# Worse, we have to force a disconnection, because the server now
1000
# doesn't realise it has a body on the wire to consume, so the
1001
# only way to recover is to abandon the connection.
1003
# To avoid having to disconnect repeatedly, we keep track of the
1004
# fact the server doesn't understand this remote method.
1005
medium._remote_is_at_least_1_2 = False
1007
return self._real_repository.get_data_stream_for_search(search)
983
1009
if response == ('ok',):
984
1010
return self._deserialise_stream(protocol)
985
1011
if response == ('NoSuchRevision', ):
986
1012
# We cannot easily identify the revision that is missing in this
987
1013
# situation without doing much more network IO. For now, bail.
988
1014
raise NoSuchRevision(self, "unknown")
989
elif (response == ('error', "Generic bzr smart protocol error: "
990
"bad request '%s'" % REQUEST_NAME) or
991
response == ('error', "Generic bzr smart protocol error: "
992
"bad request u'%s'" % REQUEST_NAME)):
993
protocol.cancel_read_body()
995
return self._real_repository.get_data_stream_for_search(search)
997
1016
raise errors.UnexpectedSmartServerResponse(response)