/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

Explicitly mark the number of keys elements in use in GraphIndex files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
from bzrlib import errors
30
30
 
 
31
_OPTION_KEY_ELEMENTS = "key_elements="
31
32
_OPTION_NODE_REFS = "node_ref_lists="
32
33
_SIGNATURE = "Bazaar Graph Index 1\n"
33
34
 
105
106
    def finish(self):
106
107
        lines = [_SIGNATURE]
107
108
        lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
108
 
        prefix_length = len(lines[0]) + len(lines[1])
 
109
        lines.append(_OPTION_KEY_ELEMENTS + str(self._key_length) + '\n')
 
110
        prefix_length = len(lines[0]) + len(lines[1]) + len(lines[2])
109
111
        # references are byte offsets. To avoid having to do nasty
110
112
        # polynomial work to resolve offsets (references to later in the 
111
113
        # file cannot be determined until all the inbetween references have
289
291
            self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1])
290
292
        except ValueError:
291
293
            raise errors.BadIndexOptions(self)
 
294
        options_line = stream.readline()
 
295
        if not options_line.startswith(_OPTION_KEY_ELEMENTS):
 
296
            raise errors.BadIndexOptions(self)
 
297
        try:
 
298
            self._key_length = int(options_line[len(_OPTION_KEY_ELEMENTS):-1])
 
299
        except ValueError:
 
300
            raise errors.BadIndexOptions(self)
292
301
 
293
302
    def iter_entries(self, keys):
294
303
        """Iterate over keys within the index.