/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/index.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-28 00:12:03 UTC
  • mfrom: (4774 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4775.
  • Revision ID: andrew.bennetts@canonical.com-20091028001203-m7lgs1wtnilgo3br
Merge lp:bzr, resolving NEWS conflict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    debug,
41
41
    errors,
42
42
    )
 
43
from bzrlib.static_tuple import StaticTuple
43
44
 
44
45
_HEADER_READV = (0, 200)
45
46
_OPTION_KEY_ELEMENTS = "key_elements="
102
103
 
103
104
    def _check_key(self, key):
104
105
        """Raise BadIndexKey if key is not a valid key for this index."""
105
 
        if type(key) != tuple:
 
106
        if type(key) not in (tuple, StaticTuple):
106
107
            raise errors.BadIndexKey(key)
107
108
        if self._key_length != len(key):
108
109
            raise errors.BadIndexKey(key)
202
203
                if reference not in self._nodes:
203
204
                    self._check_key(reference)
204
205
                    absent_references.append(reference)
 
206
            # TODO: StaticTuple
205
207
            node_refs.append(tuple(reference_list))
 
208
        # TODO: StaticTuple
206
209
        return tuple(node_refs), absent_references
207
210
 
208
211
    def add_node(self, key, value, references=()):
229
232
        if self._nodes_by_key is not None and self._key_length > 1:
230
233
            self._update_nodes_by_key(key, value, node_refs)
231
234
 
 
235
    def clear_cache(self):
 
236
        """See GraphIndex.clear_cache()
 
237
 
 
238
        This is a no-op, but we need the api to conform to a generic 'Index'
 
239
        abstraction.
 
240
        """
 
241
        
232
242
    def finish(self):
233
243
        lines = [_SIGNATURE]
234
244
        lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
458
468
            # there must be one line - the empty trailer line.
459
469
            raise errors.BadIndexData(self)
460
470
 
 
471
    def clear_cache(self):
 
472
        """Clear out any cached/memoized values.
 
473
 
 
474
        This can be called at any time, but generally it is used when we have
 
475
        extracted some information, but don't expect to be requesting any more
 
476
        from this index.
 
477
        """
 
478
 
461
479
    def external_references(self, ref_list_num):
462
480
        """Return references that are not present in this index.
463
481
        """
1223
1241
                self.__class__.__name__,
1224
1242
                ', '.join(map(repr, self._indices)))
1225
1243
 
 
1244
    def clear_cache(self):
 
1245
        """See GraphIndex.clear_cache()"""
 
1246
        for index in self._indices:
 
1247
            index.clear_cache()
 
1248
 
1226
1249
    def get_parent_map(self, keys):
1227
1250
        """See graph.StackedParentsProvider.get_parent_map"""
1228
1251
        search_keys = set(keys)