48
48
from bzrlib.trace import mutter, note, warning
51
_DEFAULT_SEARCH_DEPTH = 100
51
54
class _RpcHelper(object):
52
55
"""Mixin class that helps with issuing RPCs."""
1745
1748
if parents_map is None:
1746
1749
# Repository is not locked, so there's no cache.
1747
1750
parents_map = {}
1748
# start_set is all the keys in the cache
1749
start_set = set(parents_map)
1750
# result set is all the references to keys in the cache
1751
result_parents = set()
1752
for parents in parents_map.itervalues():
1753
result_parents.update(parents)
1754
stop_keys = result_parents.difference(start_set)
1755
# We don't need to send ghosts back to the server as a position to
1757
stop_keys.difference_update(self._unstacked_provider.missing_keys)
1758
key_count = len(parents_map)
1759
if (NULL_REVISION in result_parents
1760
and NULL_REVISION in self._unstacked_provider.missing_keys):
1761
# If we pruned NULL_REVISION from the stop_keys because it's also
1762
# in our cache of "missing" keys we need to increment our key count
1763
# by 1, because the reconsitituted SearchResult on the server will
1764
# still consider NULL_REVISION to be an included key.
1766
included_keys = start_set.intersection(result_parents)
1767
start_set.difference_update(included_keys)
1751
if _DEFAULT_SEARCH_DEPTH <= 0:
1752
(start_set, stop_keys,
1753
key_count) = graph.search_result_from_parent_map(
1754
parents_map, self._unstacked_provider.missing_keys)
1756
(start_set, stop_keys,
1757
key_count) = graph.limited_search_result_from_parent_map(
1758
parents_map, self._unstacked_provider.missing_keys,
1759
keys, depth=_DEFAULT_SEARCH_DEPTH)
1768
1760
recipe = ('manual', start_set, stop_keys, key_count)
1769
1761
body = self._serialise_search_recipe(recipe)
1770
1762
path = self.bzrdir._path_for_remote_call(self._client)