Rev 2898: Make the size of the index optionally None for the pack-names index. in http://people.ubuntu.com/~robertc/baz2.0/index

Robert Collins robertc at robertcollins.net
Mon Oct 8 00:06:17 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/index

------------------------------------------------------------
revno: 2898
revision-id: robertc at robertcollins.net-20071007230613-vjip94354mn1qcqd
parent: robertc at robertcollins.net-20071007225955-8ibbi8frtdrjt58q
committer: Robert Collins <robertc at robertcollins.net>
branch nick: index
timestamp: Mon 2007-10-08 09:06:13 +1000
message:
  Make the size of the index optionally None for the pack-names index.
modified:
  bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
  bzrlib/tests/test_index.py     test_index.py-20070712131115-lolkarso50vjr64s-2
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2007-10-07 22:59:55 +0000
+++ b/bzrlib/index.py	2007-10-07 23:06:13 +0000
@@ -242,7 +242,10 @@
         :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.
+            trip as well as requiring stat'able transports, both of which are
+            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.
         """
         self._transport = transport
         self._name = name
@@ -443,6 +446,8 @@
         keys = set(keys)
         if not keys:
             return []
+        if self._size is None and self._nodes is None:
+            self._buffer_all()
         if self._nodes is not None:
             return self._iter_entries_from_total_buffer(keys)
         else:

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2007-10-07 22:59:55 +0000
+++ b/bzrlib/tests/test_index.py	2007-10-07 23:06:13 +0000
@@ -419,11 +419,6 @@
         self.assertEqual([(0, 72)], index._parsed_byte_map)
         self.assertEqual([(None, ('name',))], index._parsed_key_map)
 
-    ### - tests:
-    # data with a reference that won't be accessed by the default readv request
-    # change the _nodes dict to a bisectable list, or perhaps an adjacent list.
-    # on result generation,
-
     def test_parsing_non_adjacent_data_trims(self):
         # generate a big enough index that we only read some of it on a typical
         # bisection lookup.
@@ -640,6 +635,11 @@
         index = self.make_index()
         self.assertEqual([], list(index.iter_entries([('a', )])))
 
+    def test_iter_missing_entry_empty_no_size(self):
+        index = self.make_index()
+        index = GraphIndex(index._transport, 'index', None)
+        self.assertEqual([], list(index.iter_entries([('a', )])))
+
     def test_iter_key_prefix_1_element_key_None(self):
         index = self.make_index()
         self.assertRaises(errors.BadIndexKey, list,



More information about the bazaar-commits mailing list