~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Aaron Bentley
  • Date: 2008-11-18 17:56:06 UTC
  • mto: This revision was merged to the branch mainline in revision 3840.
  • Revision ID: aaron@aaronbentley.com-20081118175606-195u5kcnjnedebny
Reduce inefficiency when doing make_parents_provider frequently

Show diffs side-by-side

added added

removed removed

Lines of Context:
287
287
                'Does not support nested trees', target_format)
288
288
 
289
289
 
 
290
class _UnstackedParentsProvider(object):
 
291
    """ParentsProvider for RemoteRepository that ignores stacking."""
 
292
 
 
293
    def __init__(self, remote_repository):
 
294
        self._remote_repository = remote_repository
 
295
 
 
296
    def get_parent_map(self, revision_ids):
 
297
        """See RemoteRepository.get_parent_map."""
 
298
        return self._remote_repository._get_parent_map(revision_ids)
 
299
 
 
300
 
290
301
class RemoteRepository(_RpcHelper):
291
302
    """Repository accessed over rpc.
292
303
 
334
345
        self.base = self.bzrdir.transport.base
335
346
        # Additional places to query for data.
336
347
        self._fallback_repositories = []
 
348
        self._parents_provider = None
337
349
 
338
350
    def __str__(self):
339
351
        return "%s(%s)" % (self.__class__.__name__, self.base)
883
895
        return self._real_repository._fetch_reconcile
884
896
 
885
897
    def get_parent_map(self, revision_ids):
 
898
        """See bzrlib.Graph.get_parent_map()."""
886
899
        return self._make_parents_provider().get_parent_map(revision_ids)
887
900
 
888
901
    def _get_parent_map(self, keys):
889
 
        """See bzrlib.Graph.get_parent_map()."""
 
902
        """Implementation of get_parent_map() that ignores fallbacks."""
890
903
        # Hack to build up the caching logic.
891
904
        ancestry = self._parents_map
892
905
        if ancestry is None:
1211
1224
        return self._real_repository._check_for_inconsistent_revision_parents()
1212
1225
 
1213
1226
    def _make_parents_provider(self):
1214
 
 
1215
 
        class ParentsProvider(object):
1216
 
 
1217
 
            def get_parent_map(instance, revision_ids):
1218
 
                return self._get_parent_map(revision_ids)
1219
 
 
1220
 
        providers = [r._make_parents_provider() for r in
1221
 
                     self._fallback_repositories]
1222
 
        return graph._StackedParentsProvider([ParentsProvider()] + providers)
 
1227
        if self._parents_provider is None:
 
1228
            providers = [_UnstackedParentsProvider(self)]
 
1229
            providers.extend(r._make_parents_provider() for r in
 
1230
                             self._fallback_repositories)
 
1231
            self._parents_provider = graph._StackedParentsProvider(providers)
 
1232
        return self._parents_provider
1223
1233
 
1224
1234
    def _serialise_search_recipe(self, recipe):
1225
1235
        """Serialise a graph search recipe.