Rev 5076: Add 'offset=' to the GraphIndex api, but refuse to let it be nonzero for now. in http://bzr.arbash-meinel.com/branches/bzr/lp/2.2.0b2-btree-offset
John Arbash Meinel
john at arbash-meinel.com
Fri Mar 5 17:30:54 GMT 2010
At http://bzr.arbash-meinel.com/branches/bzr/lp/2.2.0b2-btree-offset
------------------------------------------------------------
revno: 5076
revision-id: john at arbash-meinel.com-20100305173021-56x1q530woa0oq48
parent: john at arbash-meinel.com-20100305172120-fmc6vu6kdqqcnq5t
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.2.0b2-btree-offset
timestamp: Fri 2010-03-05 11:30:21 -0600
message:
Add 'offset=' to the GraphIndex api, but refuse to let it be nonzero for now.
I don't specifically need to support offset not equal to 0 for what I want,
but I want to make sure the Index constructors can take the param.
-------------- next part --------------
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/index.py 2010-03-05 17:30:21 +0000
@@ -382,7 +382,7 @@
suitable for production use. :XXX
"""
- def __init__(self, transport, name, size, unlimited_cache=False):
+ def __init__(self, transport, name, size, unlimited_cache=False, offset=0):
"""Open an index called name on transport.
:param transport: A bzrlib.transport.Transport.
@@ -394,6 +394,8 @@
avoided by having it supplied. If size is None, then bisection
support will be disabled and accessing the index will just stream
all the data.
+ :param offset: Instead of starting the index data at offset 0, start it
+ at an arbitrary offset.
"""
self._transport = transport
self._name = name
@@ -416,6 +418,9 @@
self._size = size
# The number of bytes we've read so far in trying to process this file
self._bytes_read = 0
+ self._base_offset = offset
+ if offset != 0:
+ raise NotImplementedError('GraphIndex(offset) must be 0')
def __eq__(self, other):
"""Equal when self and other were created with the same parameters."""
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/test_index.py 2010-03-05 17:30:21 +0000
@@ -399,6 +399,11 @@
trans.put_bytes('name', "not an index\n")
index = GraphIndex(trans, 'name', 13)
+ def test_open_bad_offset(self):
+ trans = self.get_transport()
+ self.assertRaises(NotImplementedError,
+ GraphIndex, trans, 'name', 13, offset=10)
+
def test_open_sets_parsed_map_empty(self):
index = self.make_index()
self.assertEqual([], index._parsed_byte_map)
More information about the bazaar-commits
mailing list