/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/fetch.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
125
125
            pb.update("Inserting stream")
126
126
            resume_tokens, missing_keys = self.sink.insert_stream(
127
127
                stream, from_format, [])
 
128
            if self.to_repository._fallback_repositories:
 
129
                missing_keys.update(
 
130
                    self._parent_inventories(search.get_keys()))
128
131
            if missing_keys:
129
132
                pb.update("Missing keys")
130
133
                stream = source.get_stream_for_missing_keys(missing_keys)
160
163
            self.from_repository, self._last_revision,
161
164
            find_ghosts=self.find_ghosts)
162
165
 
 
166
    def _parent_inventories(self, revision_ids):
 
167
        # Find all the parent revisions referenced by the stream, but
 
168
        # not present in the stream, and make sure we send their
 
169
        # inventories.
 
170
        parent_maps = self.to_repository.get_parent_map(revision_ids)
 
171
        parents = set()
 
172
        map(parents.update, parent_maps.itervalues())
 
173
        parents.discard(NULL_REVISION)
 
174
        parents.difference_update(revision_ids)
 
175
        missing_keys = set(('inventories', rev_id) for rev_id in parents)
 
176
        return missing_keys
 
177
 
163
178
 
164
179
class Inter1and2Helper(object):
165
180
    """Helper for operations that convert data from model 1 and 2
167
182
    This is for use by fetchers and converters.
168
183
    """
169
184
 
170
 
    # This is a class variable so that the test suite can override it.
171
 
    known_graph_threshold = 100
172
 
 
173
185
    def __init__(self, source):
174
186
        """Constructor.
175
187
 
231
243
        # yet, and are unlikely to in non-rich-root environments anyway.
232
244
        root_id_order.sort(key=operator.itemgetter(0))
233
245
        # Create a record stream containing the roots to create.
234
 
        if len(revs) > self.known_graph_threshold:
235
 
            graph = self.source.get_known_graph_ancestry(revs)
 
246
        if len(revs) > 100:
 
247
            # XXX: not covered by tests, should have a flag to always run
 
248
            # this. -- mbp 20100129
 
249
            graph = self.source_repo.get_known_graph_ancestry(revs)
236
250
        new_roots_stream = _new_root_data_stream(
237
251
            root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
238
252
        return [('texts', new_roots_stream)]
239
253
 
240
254
 
 
255
def _get_rich_root_heads_graph(source_repo, revision_ids):
 
256
    """Get a Graph object suitable for asking heads() for new rich roots."""
 
257
    return 
 
258
 
 
259
 
241
260
def _new_root_data_stream(
242
261
    root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
243
262
    """Generate a texts substream of synthesised root entries.