~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_map.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-15 14:49:27 UTC
  • mto: This revision was merged to the branch mainline in revision 4442.
  • Revision ID: john@arbash-meinel.com-20090615144927-odc6zdsutx7on3v1
Fix some type() == tuple to be 'type() is tuple' or '.__class__ is tuple'

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
 
122
122
    def _ensure_root(self):
123
123
        """Ensure that the root node is an object not a key."""
124
 
        if type(self._root_node) == tuple:
 
124
        if type(self._root_node) is tuple:
125
125
            # Demand-load the root
126
126
            self._root_node = self._get_node(self._root_node)
127
127
 
135
135
        :param node: A tuple key or node object.
136
136
        :return: A node object.
137
137
        """
138
 
        if type(node) == tuple:
 
138
        if type(node) is tuple:
139
139
            bytes = self._read_bytes(node)
140
140
            return _deserialise(bytes, node,
141
141
                search_key_func=self._search_key_func)
465
465
 
466
466
    def _node_key(self, node):
467
467
        """Get the key for a node whether it's a tuple or node."""
468
 
        if type(node) == tuple:
 
468
        if type(node) is tuple:
469
469
            return node
470
470
        else:
471
471
            return node._key
491
491
 
492
492
        :return: The key of the root node.
493
493
        """
494
 
        if type(self._root_node) == tuple:
 
494
        if type(self._root_node) is tuple:
495
495
            # Already saved.
496
496
            return self._root_node
497
497
        keys = list(self._root_node.serialise(self._store))
961
961
            # for whatever we are missing
962
962
            shortcut = True
963
963
            for prefix, node in self._items.iteritems():
964
 
                if type(node) is tuple:
 
964
                if node.__class__ is tuple:
965
965
                    keys[node] = (prefix, None)
966
966
                else:
967
967
                    yield node, None
1029
1029
                        # We can ignore this one
1030
1030
                        continue
1031
1031
                    node_key_filter = prefix_to_keys[search_prefix]
1032
 
                    if type(node) == tuple:
 
1032
                    if node.__class__ is tuple:
1033
1033
                        keys[node] = (search_prefix, node_key_filter)
1034
1034
                    else:
1035
1035
                        yield node, node_key_filter
1044
1044
                        if sub_prefix in length_filter:
1045
1045
                            node_key_filter.extend(prefix_to_keys[sub_prefix])
1046
1046
                    if node_key_filter: # this key matched something, yield it
1047
 
                        if type(node) == tuple:
 
1047
                        if node.__class__ is tuple:
1048
1048
                            keys[node] = (prefix, node_key_filter)
1049
1049
                        else:
1050
1050
                            yield node, node_key_filter
1182
1182
        :return: An iterable of the keys inserted by this operation.
1183
1183
        """
1184
1184
        for node in self._items.itervalues():
1185
 
            if type(node) == tuple:
 
1185
            if type(node) is tuple:
1186
1186
                # Never deserialised.
1187
1187
                continue
1188
1188
            if node._key is not None:
1199
1199
        lines.append('%s\n' % (self._search_prefix,))
1200
1200
        prefix_len = len(self._search_prefix)
1201
1201
        for prefix, node in sorted(self._items.items()):
1202
 
            if type(node) == tuple:
 
1202
            if type(node) is tuple:
1203
1203
                key = node[0]
1204
1204
            else:
1205
1205
                key = node._key[0]
1244
1244
            raise AssertionError("unserialised nodes have no refs.")
1245
1245
        refs = []
1246
1246
        for value in self._items.itervalues():
1247
 
            if type(value) == tuple:
 
1247
            if type(value) is tuple:
1248
1248
                refs.append(value)
1249
1249
            else:
1250
1250
                refs.append(value.key())