74
def recreate_search(self, repository, recipe_bytes):
75
lines = recipe_bytes.split('\n')
74
def recreate_search(self, repository, search_bytes):
75
lines = search_bytes.split('\n')
76
from bzrlib.trace import mutter
77
mutter('lines: %r', lines)
78
if lines[0] == 'ancestry-of':
80
search_result = graph.MiniSearchResult(start_key, repository)
81
return search_result, None
82
elif lines[0] == 'search':
83
return self.recreate_search_from_recipe(repository, lines[1:])
85
return (None, FailedSmartServerResponse(('BadSearch',)))
87
def recreate_search_from_recipe(self, repository, lines):
76
88
start_keys = set(lines[0].split(' '))
77
89
exclude_keys = set(lines[1].split(' '))
79
if exclude_keys != set([_mod_revision.NULL_REVISION]):
80
raise (None, FailedSmartServerResponse(('bad search',)))
81
if len(start_keys) != 1:
82
raise (None, FailedSmartServerResponse(('bad search',)))
83
start_key = list(start_keys)[0]
84
search_result = graph.MiniSearchResult(start_key, repository)
85
return search_result, None
86
90
revision_count = int(lines[2])
87
91
repository.lock_read()
156
160
def _do_repository_request(self, body_bytes):
157
161
repository = self._repository
158
162
revision_ids = set(self._revision_ids)
159
search_result, error = self.recreate_search(repository, body_bytes)
163
body_lines = body_bytes.split('\n')
164
search_result, error = self.recreate_search_from_recipe(
165
repository, body_lines)
160
166
if error is not None:
162
168
# TODO might be nice to start up the search again; but thats not