Rev 2891: * ``bzrlib.index.GraphIndex`` now requires a size parameter to the in http://people.ubuntu.com/~robertc/baz2.0/index
Robert Collins
robertc at robertcollins.net
Fri Oct 5 05:48:11 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/index
------------------------------------------------------------
revno: 2891
revision-id: robertc at robertcollins.net-20071005044747-lgtgu13o87egfupg
parent: pqm at pqm.ubuntu.com-20071005032619-b6c99y625rawducb
committer: Robert Collins <robertc at robertcollins.net>
branch nick: index
timestamp: Fri 2007-10-05 14:47:47 +1000
message:
* ``bzrlib.index.GraphIndex`` now requires a size parameter to the
constructor, for enabling bisection searches. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/tests/test_index.py test_index.py-20070712131115-lolkarso50vjr64s-2
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
=== modified file 'NEWS'
--- a/NEWS 2007-10-04 17:10:53 +0000
+++ b/NEWS 2007-10-05 04:47:47 +0000
@@ -126,6 +126,9 @@
API BREAKS:
+ * ``bzrlib.index.GraphIndex`` now requires a size parameter to the
+ constructor, for enabling bisection searches. (Robert Collins)
+
* ``CommitBuilder.record_entry_contents`` now requires the root entry of a
tree be supplied to it, previously failing to do so would trigger a
deprecation warning. (Robert Collins)
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2007-09-25 01:15:59 +0000
+++ b/bzrlib/index.py 2007-10-05 04:47:47 +0000
@@ -232,11 +232,15 @@
suitable for production use. :XXX
"""
- def __init__(self, transport, name):
+ def __init__(self, transport, name, size):
"""Open an index called name on transport.
:param transport: A bzrlib.transport.Transport.
:param name: A path to provide to transport API calls.
+ :param size: The size of the index in bytes. This is used for bisection
+ logic to perform partial index reads. While the size could be
+ obtained by statting the file this introduced an additional round
+ trip that is avoided by having it supplied.
"""
self._transport = transport
self._name = name
@@ -244,6 +248,7 @@
self._key_count = None
self._keys_by_offset = None
self._nodes_by_key = None
+ self._size = size
def _buffer_all(self):
"""Buffer all the index data.
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2007-08-08 04:45:55 +0000
+++ b/bzrlib/tests/test_index.py 2007-10-05 04:47:47 +0000
@@ -358,13 +358,13 @@
builder.add_node(key, value, references)
stream = builder.finish()
trans = self.get_transport()
- trans.put_file('index', stream)
- return GraphIndex(trans, 'index')
+ size = trans.put_file('index', stream)
+ return GraphIndex(trans, 'index', size)
def test_open_bad_index_no_error(self):
trans = self.get_transport()
trans.put_bytes('name', "not an index\n")
- index = GraphIndex(trans, 'name')
+ index = GraphIndex(trans, 'name', 13)
def test_iter_all_entries_empty(self):
index = self.make_index()
@@ -494,7 +494,7 @@
def test_validate_bad_index_errors(self):
trans = self.get_transport()
trans.put_bytes('name', "not an index\n")
- index = GraphIndex(trans, 'name')
+ index = GraphIndex(trans, 'name', 13)
self.assertRaises(errors.BadIndexFormatSignature, index.validate)
def test_validate_bad_node_refs(self):
@@ -539,12 +539,12 @@
builder.add_node(key, value, references)
stream = builder.finish()
trans = self.get_transport()
- trans.put_file(name, stream)
- return GraphIndex(trans, name)
+ size = trans.put_file(name, stream)
+ return GraphIndex(trans, name, size)
def test_open_missing_index_no_error(self):
trans = self.get_transport()
- index1 = GraphIndex(trans, 'missing')
+ index1 = GraphIndex(trans, 'missing', 100)
index = CombinedGraphIndex([index1])
def test_add_index(self):
@@ -677,7 +677,7 @@
def test_validate_bad_child_index_errors(self):
trans = self.get_transport()
trans.put_bytes('name', "not an index\n")
- index1 = GraphIndex(trans, 'name')
+ index1 = GraphIndex(trans, 'name', 13)
index = CombinedGraphIndex([index1])
self.assertRaises(errors.BadIndexFormatSignature, index.validate)
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-10-04 05:30:08 +0000
+++ b/bzrlib/tests/test_knit.py 2007-10-05 04:47:47 +0000
@@ -2095,8 +2095,8 @@
builder.add_node(node, references, value)
stream = builder.finish()
trans = self.get_transport()
- trans.put_file(name, stream)
- return GraphIndex(trans, name)
+ size = trans.put_file(name, stream)
+ return GraphIndex(trans, name, size)
def two_graph_index(self, deltas=False, catch_adds=False):
"""Build a two-graph index.
@@ -2406,8 +2406,8 @@
builder.add_node(node, references)
stream = builder.finish()
trans = self.get_transport()
- trans.put_file(name, stream)
- return GraphIndex(trans, name)
+ size = trans.put_file(name, stream)
+ return GraphIndex(trans, name, size)
def test_parents_deltas_incompatible(self):
index = CombinedGraphIndex([])
More information about the bazaar-commits
mailing list