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

  • Committer: Shannon Weyrick
  • Date: 2011-11-16 20:59:10 UTC
  • mto: This revision was merged to the branch mainline in revision 6268.
  • Revision ID: weyrick@mozek.us-20111116205910-1xbpqbimbw3fvfqw
A version of the patch, based on suggestions from John Meinel, which detects an empty page differently to avoid false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
294
294
            flag when writing out. This is used by the _spill_mem_keys_to_disk
295
295
            functionality.
296
296
        """
 
297
        new_leaf = False
297
298
        if rows[-1].writer is None:
298
299
            # opening a new leaf chunk;
 
300
            new_leaf = True
299
301
            for pos, internal_row in enumerate(rows[:-1]):
300
302
                # flesh out any internal nodes that are needed to
301
303
                # preserve the height of the tree
320
322
                optimize_for_size=self._optimize_for_size)
321
323
            rows[-1].writer.write(_LEAF_FLAG)
322
324
        if rows[-1].writer.write(line):
 
325
            # if we failed to write, despite having an empty page to write to,
 
326
            # then line is too big. raising the error avoids infinite recursion
 
327
            # searching for a suitably large page that will not be found.
 
328
            if new_leaf:
 
329
                raise errors.BadIndexKey(string_key)
323
330
            # this key did not fit in the node:
324
331
            rows[-1].finish_node()
325
332
            key_line = string_key + "\n"