~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/identitymap.py

  • Committer: Robert Collins
  • Date: 2005-10-11 01:05:24 UTC
  • mto: This revision was merged to the branch mainline in revision 1438.
  • Revision ID: robertc@robertcollins.net-20051011010524-e258bc8d051cc9d2
add a cache bound to Transactions, and a precious facility, so that we keep inventory.weave in memory, but can discard weaves for other such files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        if self._weave_key(id) in self._map:
35
35
            raise errors.BzrError('weave %s already in the identity map' % id)
36
36
        self._map[self._weave_key(id)] = weave
 
37
        self._reverse_map[weave] = self._weave_key(id)
37
38
 
38
39
    def find_weave(self, id):
39
40
        """Return the weave for 'id', or None if it is not present."""
42
43
    def __init__(self):
43
44
        super(IdentityMap, self).__init__()
44
45
        self._map = {}
 
46
        self._reverse_map = {}
 
47
 
 
48
    def remove_object(self, an_object):
 
49
        """Remove object from map if it is present."""
 
50
        if an_object in self._reverse_map:
 
51
            self._map.pop(self._reverse_map[an_object])
 
52
            self._reverse_map.pop(an_object)
 
53
        
45
54
 
46
55
    def _weave_key(self, id):
47
56
        """Return the key for a weaves id."""