/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-24 23:19:12 UTC
  • mfrom: (4190.1.6 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090324231912-rb0kgktzkvge8aea
(robertc) Negatively cache ghosts and misses during read-locks in
        RemoteRepository. (Robert Collins, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
        from revision_ids is returned. The verb takes a body containing the
135
135
        current search state, see do_body for details.
136
136
 
 
137
        If 'include-missing:' is in revision_ids, ghosts encountered in the
 
138
        graph traversal for getting parent data are included in the result with
 
139
        a prefix of 'missing:'.
 
140
 
137
141
        :param repository: The repository to query in.
138
142
        :param revision_ids: The utf8 encoded revision_id to answer for.
139
143
        """
158
162
    def _do_repository_request(self, body_bytes):
159
163
        repository = self._repository
160
164
        revision_ids = set(self._revision_ids)
 
165
        include_missing = 'include-missing:' in revision_ids
 
166
        if include_missing:
 
167
            revision_ids.remove('include-missing:')
161
168
        body_lines = body_bytes.split('\n')
162
169
        search_result, error = self.recreate_search_from_recipe(
163
170
            repository, body_lines)
178
185
        while next_revs:
179
186
            queried_revs.update(next_revs)
180
187
            parent_map = repo_graph.get_parent_map(next_revs)
 
188
            current_revs = next_revs
181
189
            next_revs = set()
182
 
            for revision_id, parents in parent_map.iteritems():
183
 
                # adjust for the wire
184
 
                if parents == (_mod_revision.NULL_REVISION,):
185
 
                    parents = ()
186
 
                # prepare the next query
187
 
                next_revs.update(parents)
188
 
                if revision_id not in client_seen_revs:
 
190
            for revision_id in current_revs:
 
191
                missing_rev = False
 
192
                parents = parent_map.get(revision_id)
 
193
                if parents is not None:
 
194
                    # adjust for the wire
 
195
                    if parents == (_mod_revision.NULL_REVISION,):
 
196
                        parents = ()
 
197
                    # prepare the next query
 
198
                    next_revs.update(parents)
 
199
                    encoded_id = revision_id
 
200
                else:
 
201
                    missing_rev = True
 
202
                    encoded_id = "missing:" + revision_id
 
203
                    parents = []
 
204
                if (revision_id not in client_seen_revs and
 
205
                    (not missing_rev or include_missing)):
189
206
                    # Client does not have this revision, give it to it.
190
207
                    # add parents to the result
191
 
                    result[revision_id] = parents
 
208
                    result[encoded_id] = parents
192
209
                    # Approximate the serialized cost of this revision_id.
193
 
                    size_so_far += 2 + len(revision_id) + sum(map(len, parents))
 
210
                    size_so_far += 2 + len(encoded_id) + sum(map(len, parents))
194
211
            # get all the directly asked for parents, and then flesh out to
195
212
            # 64K (compressed) or so. We do one level of depth at a time to
196
213
            # stay in sync with the client. The 250000 magic number is