~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Andrew Bennetts
  • Date: 2009-03-05 12:48:48 UTC
  • mto: (4086.1.2 hpss-integration)
  • mto: This revision was merged to the branch mainline in revision 4087.
  • Revision ID: andrew.bennetts@canonical.com-20090305124848-j7bsh3mxwpgevbbw
Better wire protocol: don't shoehorn MiniSearchResult serialisation into previous serialisation format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
        # is expected)
72
72
        return None
73
73
 
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':
 
79
            start_key = lines[1]
 
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:])
 
84
        else:
 
85
            return (None, FailedSmartServerResponse(('BadSearch',)))
 
86
 
 
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(' '))
78
 
        if lines[2] == 'n/a':
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()
88
92
        try:
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:
161
167
            return error
162
168
        # TODO might be nice to start up the search again; but thats not