~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/btree_index.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""B+Tree indices"""
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import cStringIO
21
23
 
22
24
from bzrlib.lazy_import import lazy_import
197
199
            new_backing_file, size = self._spill_mem_keys_without_combining()
198
200
        # Note: The transport here isn't strictly needed, because we will use
199
201
        #       direct access to the new_backing._file object
200
 
        new_backing = BTreeGraphIndex(transport.get_transport('.'),
 
202
        new_backing = BTreeGraphIndex(transport.get_transport_from_path('.'),
201
203
                                      '<temp>', size)
202
204
        # GC will clean up the file
203
205
        new_backing._file = new_backing_file
294
296
            flag when writing out. This is used by the _spill_mem_keys_to_disk
295
297
            functionality.
296
298
        """
 
299
        new_leaf = False
297
300
        if rows[-1].writer is None:
298
301
            # opening a new leaf chunk;
 
302
            new_leaf = True
299
303
            for pos, internal_row in enumerate(rows[:-1]):
300
304
                # flesh out any internal nodes that are needed to
301
305
                # preserve the height of the tree
320
324
                optimize_for_size=self._optimize_for_size)
321
325
            rows[-1].writer.write(_LEAF_FLAG)
322
326
        if rows[-1].writer.write(line):
 
327
            # if we failed to write, despite having an empty page to write to,
 
328
            # then line is too big. raising the error avoids infinite recursion
 
329
            # searching for a suitably large page that will not be found.
 
330
            if new_leaf:
 
331
                raise errors.BadIndexKey(string_key)
323
332
            # this key did not fit in the node:
324
333
            rows[-1].finish_node()
325
334
            key_line = string_key + "\n"