Rev 2383: Rather than falling over when the page size is to small, just increase it and try again. in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
John Arbash Meinel
john at arbash-meinel.com
Fri Feb 23 22:09:28 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
------------------------------------------------------------
revno: 2383
revision-id: john at arbash-meinel.com-20070223220821-yjinik850b8szgqj
parent: john at arbash-meinel.com-20070223213737-k94ppwskpppa7nds
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Fri 2007-02-23 16:08:21 -0600
message:
Rather than falling over when the page size is to small, just increase it and try again.
modified:
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2007-02-23 21:19:37 +0000
+++ b/bzrlib/dirstate.py 2007-02-23 22:08:21 +0000
@@ -437,7 +437,9 @@
# So put this range back and try again. But we know we have to
# increase the page size, because a single read did not contain
# a record break (so records must be larger than page_size)
- raise errors.BisectPageSizeTooSmall(page_size)
+ page_size *= 2
+ pending.append((low, high, cur_files))
+ continue
# Check the first and last entries, in case they are partial, or if
# we don't care about the rest of this page
@@ -453,8 +455,10 @@
if len(first_fields) <= 2:
# We didn't even get a filename here... what do we do?
- # For now, just fall over
- raise errors.BisectPageSizeTooSmall(page_size)
+ # Try a large page size and repeat this query
+ page_size *= 2
+ pending.append((low, high, cur_files))
+ continue
else:
# Find what entries we are looking for, which occur before and
# after this first record.
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-02-23 21:19:37 +0000
+++ b/bzrlib/errors.py 2007-02-23 22:08:21 +0000
@@ -163,18 +163,6 @@
_fmt = "The tree builder is already building a tree."
-class BisectPageSizeTooSmall(BzrError):
-
- _fmt = ("The dirstate bisect page size %(size)s is too small."
- " We were unable to read an entire record.")
-
- internal_error = True
-
- def __init__(self, size):
- BzrError.__init__(self)
- self.size = size
-
-
class BzrCheckError(BzrError):
_fmt = "Internal check failed: %(message)s"
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2007-02-23 21:37:37 +0000
+++ b/bzrlib/tests/test_dirstate.py 2007-02-23 22:08:21 +0000
@@ -1124,15 +1124,16 @@
self.assertBisect([[expected['b'], expected['b2']]], state, ['b'])
def test_bisect_page_size_too_small(self):
- """We should raise an error if we detect a field longer than page_size.
-
- This is a safety check, since we know we are reading in pages, and we
- expect to fit at least slightly more than 1 record per page.
- """
+ """If the page size is too small, we will auto increase it."""
tree, state, expected = self.create_basic_dirstate()
state._bisect_page_size = 50
- self.assertRaises(errors.BisectPageSizeTooSmall,
- state._bisect, [('b', 'e')])
+ self.assertBisect([None], state, ['b/e'])
+ self.assertBisect([[expected['a']]], state, ['a'])
+ self.assertBisect([[expected['b']]], state, ['b'])
+ self.assertBisect([[expected['b/c']]], state, ['b/c'])
+ self.assertBisect([[expected['b/d']]], state, ['b/d'])
+ self.assertBisect([[expected['b/d/e']]], state, ['b/d/e'])
+ self.assertBisect([[expected['f']]], state, ['f'])
def test_bisect_missing(self):
"""Test that bisect return None if it cannot find a path."""
More information about the bazaar-commits
mailing list