/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/remote.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:
839
839
        if not self._lock_mode:
840
840
            self._lock_mode = 'r'
841
841
            self._lock_count = 1
842
 
            self._unstacked_provider.enable_cache(cache_misses=False)
 
842
            self._unstacked_provider.enable_cache(cache_misses=True)
843
843
            if self._real_repository is not None:
844
844
                self._real_repository.lock_read()
845
845
        else:
1241
1241
        # TODO: Manage this incrementally to avoid covering the same path
1242
1242
        # repeatedly. (The server will have to on each request, but the less
1243
1243
        # work done the better).
 
1244
        #
 
1245
        # Negative caching notes:
 
1246
        # new server sends missing when a request including the revid
 
1247
        # 'include-missing:' is present in the request.
 
1248
        # missing keys are serialised as missing:X, and we then call
 
1249
        # provider.note_missing(X) for-all X
1244
1250
        parents_map = self._unstacked_provider.get_cached_map()
1245
1251
        if parents_map is None:
1246
1252
            # Repository is not locked, so there's no cache.
1247
1253
            parents_map = {}
 
1254
        # start_set is all the keys in the cache
1248
1255
        start_set = set(parents_map)
 
1256
        # result set is all the references to keys in the cache
1249
1257
        result_parents = set()
1250
1258
        for parents in parents_map.itervalues():
1251
1259
            result_parents.update(parents)
1252
1260
        stop_keys = result_parents.difference(start_set)
 
1261
        # We don't need to send ghosts back to the server as a position to
 
1262
        # stop either.
 
1263
        stop_keys.difference_update(self._unstacked_provider.missing_keys)
1253
1264
        included_keys = start_set.intersection(result_parents)
1254
1265
        start_set.difference_update(included_keys)
1255
1266
        recipe = ('manual', start_set, stop_keys, len(parents_map))
1260
1271
                raise ValueError(
1261
1272
                    "key %r not a plain string" % (key,))
1262
1273
        verb = 'Repository.get_parent_map'
1263
 
        args = (path,) + tuple(keys)
 
1274
        args = (path, 'include-missing:') + tuple(keys)
1264
1275
        try:
1265
1276
            response = self._call_with_body_bytes_expecting_body(
1266
1277
                verb, args, body)
1294
1305
                if len(d) > 1:
1295
1306
                    revision_graph[d[0]] = d[1:]
1296
1307
                else:
1297
 
                    # No parents - so give the Graph result (NULL_REVISION,).
1298
 
                    revision_graph[d[0]] = (NULL_REVISION,)
 
1308
                    # No parents:
 
1309
                    if d[0].startswith('missing:'):
 
1310
                        revid = d[0][8:]
 
1311
                        self._unstacked_provider.note_missing_key(revid)
 
1312
                    else:
 
1313
                        # no parents - so give the Graph result
 
1314
                        # (NULL_REVISION,).
 
1315
                        revision_graph[d[0]] = (NULL_REVISION,)
1299
1316
            return revision_graph
1300
1317
 
1301
1318
    @needs_read_lock