Rev 3181: Review feedback. in http://people.ubuntu.com/~robertc/baz2.0/remote.graph
Robert Collins
robertc at robertcollins.net
Mon Jan 14 22:48:21 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/remote.graph
------------------------------------------------------------
revno: 3181
revision-id:robertc at robertcollins.net-20080114224807-zhx2hiy2902zr7aw
parent: robertc at robertcollins.net-20080114051607-8icqda4bvrc2u1xe
committer: Robert Collins <robertc at robertcollins.net>
branch nick: remote.graph
timestamp: Tue 2008-01-15 09:48:07 +1100
message:
Review feedback.
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-01-14 04:46:08 +0000
+++ b/bzrlib/remote.py 2008-01-14 22:48:07 +0000
@@ -746,6 +746,24 @@
self._parents_map.update(self._get_parent_map(missing_revisions))
return dict((k, ancestry[k]) for k in keys if k in ancestry)
+ def _response_is_unknown_method(self, response, verb):
+ """Return True if response is an unknonwn method response to verb.
+
+ :param response: The response from a smart client call_expecting_body
+ call.
+ :param verb: The verb used in that call.
+ :return: True if an unknown method was encountered.
+ """
+ # This might live better on
+ # bzrlib.smart.protocol.SmartClientRequestProtocolOne
+ if (response[0] == ('error', "Generic bzr smart protocol error: "
+ "bad request '%s'" % verb) or
+ response[0] == ('error', "Generic bzr smart protocol error: "
+ "bad request u'%s'" % verb)):
+ response[1].cancel_read_body()
+ return True
+ return False
+
def _get_parent_map(self, keys):
"""Helper for get_parent_map that performs the RPC."""
keys = set(keys)
@@ -759,9 +777,18 @@
path = self.bzrdir._path_for_remote_call(self._client)
for key in keys:
assert type(key) is str
+ verb = 'Repository.get_parent_map'
response = self._client.call_expecting_body(
- 'Repository.get_parent_map', path, *keys)
- if response[0][0] not in ['ok']:
+ verb, path, *keys)
+ if self._response_is_unknown_method(response, verb):
+ # Server that does not support this method, get the whole graph.
+ response = self._client.call_expecting_body(
+ 'Repository.get_revision_graph', path, '')
+ if response[0][0] not in ['ok', 'nosuchrevision']:
+ reponse[1].cancel_read_body()
+ raise errors.UnexpectedSmartServerResponse(response[0])
+ elif response[0][0] not in ['ok']:
+ reponse[1].cancel_read_body()
raise errors.UnexpectedSmartServerResponse(response[0])
if response[0][0] == 'ok':
coded = response[1].read_body_bytes()
=== modified file 'bzrlib/smart/repository.py'
--- a/bzrlib/smart/repository.py 2008-01-14 04:46:08 +0000
+++ b/bzrlib/smart/repository.py 2008-01-14 22:48:07 +0000
@@ -69,10 +69,10 @@
from revision_ids is returned.
:param repository: The repository to query in.
- :param revision_id:s The utf8 encoded revision_id to answer.
+ :param revision_ids: The utf8 encoded revision_id to answer for.
:return: A smart server response where the body contains an utf8
- encoded flattened list of the revision graph, (the same format as
- Repository.get_revision_graph).
+ encoded flattened list of the parents of the revisions, (the same
+ format as Repository.get_revision_graph).
"""
lines = []
repo_graph = repository.get_graph()
@@ -93,6 +93,7 @@
result[revision_id] = parents
# prepare the next query
next_revs.update(parents)
+ # Approximate the serialized cost of this revision_id.
size_so_far += 2 + len(revision_id) + sum(map(len, parents))
# get all the directly asked for parents, and then flesh out to
# 64K or so.
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2008-01-14 05:16:07 +0000
+++ b/bzrlib/tests/test_remote.py 2008-01-14 22:48:07 +0000
@@ -547,7 +547,8 @@
class TestRepositoryGetGraph(TestRemoteRepository):
def test_get_graph(self):
- # get_graph returns a graph with get_parent_map as the repository.
+ # get_graph returns a graph with the repository as the
+ # parents_provider.
responses = []
transport_path = 'quack'
repo, client = self.setup_fake_client_and_repository(
More information about the bazaar-commits
mailing list