391
394
def get_graph(self, other_repository=None):
392
395
"""Return the graph for this repository format"""
394
return self._real_repository.get_graph(other_repository)
396
parents_provider = self
397
if (other_repository is not None and
398
other_repository.bzrdir.transport.base !=
399
self.bzrdir.transport.base):
400
parents_provider = graph._StackedParentsProvider(
401
[parents_provider, other_repository._make_parents_provider()])
402
return graph.Graph(parents_provider)
396
404
def gather_stats(self, revid=None, committers=None):
397
405
"""See Repository.gather_stats()."""
726
737
self._ensure_real()
727
738
return self._real_repository.iter_files_bytes(desired_files)
740
def get_parent_map(self, keys):
741
"""See bzrlib.Graph.get_parent_map()."""
742
# Hack to build up the caching logic.
743
ancestry = self._parents_map
744
missing_revisions = set(key for key in keys if key not in ancestry)
745
if missing_revisions:
746
self._parents_map.update(self._get_parent_map(missing_revisions))
747
return dict((k, ancestry[k]) for k in keys if k in ancestry)
749
def _response_is_unknown_method(self, response, verb):
750
"""Return True if response is an unknonwn method response to verb.
752
:param response: The response from a smart client call_expecting_body
754
:param verb: The verb used in that call.
755
:return: True if an unknown method was encountered.
757
# This might live better on
758
# bzrlib.smart.protocol.SmartClientRequestProtocolOne
759
if (response[0] == ('error', "Generic bzr smart protocol error: "
760
"bad request '%s'" % verb) or
761
response[0] == ('error', "Generic bzr smart protocol error: "
762
"bad request u'%s'" % verb)):
763
response[1].cancel_read_body()
767
def _get_parent_map(self, keys):
768
"""Helper for get_parent_map that performs the RPC."""
770
if NULL_REVISION in keys:
771
keys.discard(NULL_REVISION)
772
found_parents = {NULL_REVISION:()}
777
path = self.bzrdir._path_for_remote_call(self._client)
779
assert type(key) is str
780
verb = 'Repository.get_parent_map'
781
response = self._client.call_expecting_body(
783
if self._response_is_unknown_method(response, verb):
784
# Server that does not support this method, get the whole graph.
785
response = self._client.call_expecting_body(
786
'Repository.get_revision_graph', path, '')
787
if response[0][0] not in ['ok', 'nosuchrevision']:
788
reponse[1].cancel_read_body()
789
raise errors.UnexpectedSmartServerResponse(response[0])
790
elif response[0][0] not in ['ok']:
791
reponse[1].cancel_read_body()
792
raise errors.UnexpectedSmartServerResponse(response[0])
793
if response[0][0] == 'ok':
794
coded = response[1].read_body_bytes()
798
lines = coded.split('\n')
801
d = tuple(line.split())
803
revision_graph[d[0]] = d[1:]
805
# No parents - so give the Graph result (NULL_REVISION,).
806
revision_graph[d[0]] = (NULL_REVISION,)
807
return revision_graph
730
810
def get_signature_text(self, revision_id):
731
811
self._ensure_real()