~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: John Arbash Meinel
  • Date: 2008-12-13 03:19:40 UTC
  • mto: This revision was merged to the branch mainline in revision 3912.
  • Revision ID: john@arbash-meinel.com-20081213031940-goymz22b10o9zu32
Change the XMLSerializer.read_inventory_from_string api.

This allows us to pass in the entry cache, rather than using a global.
This gives a lifetime to the cache, and eliminates some of the
concerns about expecting a different IE from different serializers, etc.

The cache is also cleared when the repo is unlocked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    check,
26
26
    debug,
27
27
    errors,
 
28
    fifo_cache,
28
29
    generate_ids,
29
30
    gpg,
30
31
    graph,
842
843
        # Should fetch trigger a reconcile after the fetch? Only needed for
843
844
        # some repository formats that can suffer internal inconsistencies.
844
845
        self._fetch_reconcile = False
 
846
        # An InventoryEntry cache, used during deserialization
 
847
        self._inventory_entry_cache = fifo_cache.FIFOCache(10*1024)
845
848
 
846
849
    def __repr__(self):
847
850
        return '%s(%r)' % (self.__class__.__name__,
1145
1148
                raise errors.BzrError(
1146
1149
                    'Must end write groups before releasing write locks.')
1147
1150
        self.control_files.unlock()
 
1151
        if self.control_files._lock_count == 0:
 
1152
            self._inventory_entry_cache.clear()
1148
1153
        for repo in self._fallback_repositories:
1149
1154
            repo.unlock()
1150
1155
 
1696
1701
        :param revision_id: The expected revision id of the inventory.
1697
1702
        :param xml: A serialised inventory.
1698
1703
        """
1699
 
        result = self._serializer.read_inventory_from_string(xml, revision_id)
 
1704
        result = self._serializer.read_inventory_from_string(xml, revision_id,
 
1705
                    entry_cache=self._inventory_entry_cache)
1700
1706
        if result.revision_id != revision_id:
1701
1707
            raise AssertionError('revision id mismatch %s != %s' % (
1702
1708
                result.revision_id, revision_id))