~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-06 19:35:39 UTC
  • mfrom: (4086.1.4 hpss-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090306193539-h0q6dlyayhgcehta
(robertc, andrew) Add Branch.get_tags_dict RPC;
        Add optional 'fetch_spec' argument to Repository.fetch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from bzrlib import (
29
29
    errors,
 
30
    graph,
30
31
    osutils,
31
32
    pack,
32
33
    )
70
71
        # is expected)
71
72
        return None
72
73
 
73
 
    def recreate_search(self, repository, recipe_bytes):
74
 
        lines = recipe_bytes.split('\n')
 
74
    def recreate_search(self, repository, search_bytes):
 
75
        lines = search_bytes.split('\n')
 
76
        if lines[0] == 'ancestry-of':
 
77
            heads = lines[1:]
 
78
            search_result = graph.PendingAncestryResult(heads, repository)
 
79
            return search_result, None
 
80
        elif lines[0] == 'search':
 
81
            return self.recreate_search_from_recipe(repository, lines[1:])
 
82
        else:
 
83
            return (None, FailedSmartServerResponse(('BadSearch',)))
 
84
 
 
85
    def recreate_search_from_recipe(self, repository, lines):
75
86
        start_keys = set(lines[0].split(' '))
76
87
        exclude_keys = set(lines[1].split(' '))
77
88
        revision_count = int(lines[2])
93
104
                # the excludes list considers ghosts and ensures that ghost
94
105
                # filling races are not a problem.
95
106
                return (None, FailedSmartServerResponse(('NoSuchRevision',)))
96
 
            return (search, None)
 
107
            return (search_result, None)
97
108
        finally:
98
109
            repository.unlock()
99
110
 
147
158
    def _do_repository_request(self, body_bytes):
148
159
        repository = self._repository
149
160
        revision_ids = set(self._revision_ids)
150
 
        search, error = self.recreate_search(repository, body_bytes)
 
161
        body_lines = body_bytes.split('\n')
 
162
        search_result, error = self.recreate_search_from_recipe(
 
163
            repository, body_lines)
151
164
        if error is not None:
152
165
            return error
153
166
        # TODO might be nice to start up the search again; but thats not
154
167
        # written or tested yet.
155
 
        client_seen_revs = set(search.get_result().get_keys())
 
168
        client_seen_revs = set(search_result.get_keys())
156
169
        # Always include the requested ids.
157
170
        client_seen_revs.difference_update(revision_ids)
158
171
        lines = []
349
362
        repository = self._repository
350
363
        repository.lock_read()
351
364
        try:
352
 
            search, error = self.recreate_search(repository, body_bytes)
 
365
            search_result, error = self.recreate_search(repository, body_bytes)
353
366
            if error is not None:
354
367
                repository.unlock()
355
368
                return error
356
 
            search = search.get_result()
357
369
            source = repository._get_source(self._to_format)
358
 
            stream = source.get_stream(search)
 
370
            stream = source.get_stream(search_result)
359
371
        except Exception:
360
372
            exc_info = sys.exc_info()
361
373
            try: