~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-03 04:55:02 UTC
  • mto: This revision was merged to the branch mainline in revision 4887.
  • Revision ID: john@arbash-meinel.com-20091203045502-uvhmg6b1yjbzzt8q
Change from being a per-serializer attribute to being a per-repo attribute.
This means we have some churn on *all* of the serializer apis, but it means
we *don't* have churn on all of the repository apis.

It makes it more thread-safe, since serializers are global instances.
Repositories aren't currently thread-safe anyway. (get_record_stream() specifically
is known not to be thread-safe on 2a format repos.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1314
1314
        self._fallback_repositories = []
1315
1315
        # An InventoryEntry cache, used during deserialization
1316
1316
        self._inventory_entry_cache = fifo_cache.FIFOCache(10*1024)
 
1317
        # Is it safe to return inventory entries directly from the entry cache,
 
1318
        # rather copying them?
 
1319
        self._safe_to_return_from_cache = False
1317
1320
 
1318
1321
    def __repr__(self):
1319
1322
        if self._fallback_repositories:
2431
2434
        :param xml: A serialised inventory.
2432
2435
        """
2433
2436
        result = self._serializer.read_inventory_from_string(xml, revision_id,
2434
 
                    entry_cache=self._inventory_entry_cache)
 
2437
                    entry_cache=self._inventory_entry_cache,
 
2438
                    return_from_cache=self._safe_to_return_from_cache)
2435
2439
        if result.revision_id != revision_id:
2436
2440
            raise AssertionError('revision id mismatch %s != %s' % (
2437
2441
                result.revision_id, revision_id))
3840
3844
        pending_revisions = []
3841
3845
        parent_map = self.source.get_parent_map(revision_ids)
3842
3846
        self._fetch_parent_invs_for_stacking(parent_map, cache)
3843
 
        self.source._format._serializer.safe_to_use_cache_items = True
 
3847
        self.source._safe_to_return_from_cache = True
3844
3848
        for tree in self.source.revision_trees(revision_ids):
3845
3849
            # Find a inventory delta for this revision.
3846
3850
            # Find text entries that need to be copied, too.
3894
3898
            pending_revisions.append(revision)
3895
3899
            cache[current_revision_id] = tree
3896
3900
            basis_id = current_revision_id
3897
 
        self.source._format._serializer.safe_to_use_cache_items = False
 
3901
        self.source._safe_to_return_from_cache = False
3898
3902
        # Copy file texts
3899
3903
        from_texts = self.source.texts
3900
3904
        to_texts = self.target.texts
3979
3983
                basis_id = self._fetch_batch(batch, basis_id, cache,
3980
3984
                                             a_graph=a_graph)
3981
3985
            except:
3982
 
                self.source._format._serializer.safe_to_use_cache_items = False
 
3986
                self.source._safe_to_return_from_cache = False
3983
3987
                self.target.abort_write_group()
3984
3988
                raise
3985
3989
            else: