~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/btree_index.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-25 16:24:09 UTC
  • mto: This revision was merged to the branch mainline in revision 3688.
  • Revision ID: john@arbash-meinel.com-20080825162409-0766y19zjs45m87i
Do a bit more work to get all the tests to pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import sha
26
26
import struct
27
27
import tempfile
 
28
import time
28
29
import zlib
29
30
 
30
31
from bzrlib import (
59
60
miss_attempts = 0  # Missed this entry while looking up
60
61
bisect_shortcut = [0, 0]
61
62
dupes = [0]
 
63
_add_node_time = [0.0]
62
64
 
63
65
 
64
66
class _BuilderRow(object):
85
87
            del byte_lines[-1]
86
88
            skipped_bytes = padding
87
89
        self.spool.writelines(byte_lines)
88
 
        if (self.spool.tell() + skipped_bytes) % _PAGE_SIZE != 0:
89
 
            raise AssertionError("incorrect node length")
 
90
        remainder = (self.spool.tell() + skipped_bytes) % _PAGE_SIZE
 
91
        if remainder != 0:
 
92
            raise AssertionError("incorrect node length: %d, %d"
 
93
                                 % (self.spool.tell(), remainder))
90
94
        self.nodes += 1
91
95
        self.writer = None
92
96
 
391
395
            copied_len = osutils.pumpfile(row.spool, result)
392
396
            if copied_len != (row.nodes - 1) * _PAGE_SIZE:
393
397
                if type(row) != _LeafBuilderRow:
394
 
                    raise AssertionError("Not enough data copied")
 
398
                    raise AssertionError("Incorrect amount of data copied"
 
399
                        " expected: %d, got: %d"
 
400
                        % ((row.nodes - 1) * _PAGE_SIZE,
 
401
                           copied_len))
395
402
        result.flush()
396
403
        size = result.tell()
397
404
        result.seek(0)