~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_map.py

Get a working chk_map using inventory implementation bootstrapped.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
            result._map(key, value)
82
82
        return result._save()
83
83
 
84
 
    def iteritems(self):
 
84
    def iteritems(self, key_filter=None):
85
85
        """Iterate over the entire CHKMap's contents."""
86
86
        self._ensure_root()
87
 
        for name, key, in self._root_node._nodes.iteritems():
88
 
            bytes = self._read_bytes(key)
89
 
            yield name, ValueNode.deserialise(bytes).value
 
87
        if key_filter is not None:
 
88
            for name, key, in self._root_node._nodes.iteritems():
 
89
                if name in key_filter:
 
90
                    bytes = self._read_bytes(key)
 
91
                    yield name, ValueNode.deserialise(bytes).value
 
92
        else:
 
93
            for name, key, in self._root_node._nodes.iteritems():
 
94
                bytes = self._read_bytes(key)
 
95
                yield name, ValueNode.deserialise(bytes).value
90
96
 
91
97
    def _map(self, key, value):
92
98
        """Map key to value."""
152
158
        self._nodes = nodes
153
159
        self._key = key
154
160
 
 
161
    def refs(self):
 
162
        """Get the CHK key references this node holds."""
 
163
        return self._nodes.values()
 
164
 
155
165
    def remove_child(self, name):
156
166
        """Remove name from the node.
157
167