Rev 2598: Record the number of node reference lists a particular index has. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Thu Jul 12 14:51:42 BST 2007


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

------------------------------------------------------------
revno: 2598
revision-id: robertc at robertcollins.net-20070712135140-6y4vgazp2dsrz45b
parent: robertc at robertcollins.net-20070712134339-c5vx9dbdb9n22zte
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Thu 2007-07-12 23:51:40 +1000
message:
  Record the number of node reference lists a particular index has.
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-07-12 13:43:39 +0000
+++ b/bzrlib/index.py	2007-07-12 13:51:40 +0000
@@ -20,14 +20,26 @@
 
 from bzrlib import errors
 
+_OPTION_NODE_REFS = "node_ref_lists="
 _SIGNATURE = "Bazaar Graph Index 1\n"
 
 
 class GraphIndexBuilder(object):
     """A builder that can build a GraphIndex."""
 
+    def __init__(self, reference_lists=0):
+        """Create a GraphIndex builder.
+
+        :param reference_lists: The number of node references lists for each
+            entry.
+        """
+        self.reference_lists = reference_lists
+
     def finish(self):
-        return StringIO(_SIGNATURE + '\n')
+        lines = [_SIGNATURE]
+        lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
+        lines.append('\n')
+        return StringIO(''.join(lines))
 
 
 class GraphIndex(object):

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2007-07-12 13:43:39 +0000
+++ b/bzrlib/tests/test_index.py	2007-07-12 13:51:40 +0000
@@ -27,7 +27,13 @@
         builder = GraphIndexBuilder()
         stream = builder.finish()
         contents = stream.read()
-        self.assertEqual("Bazaar Graph Index 1\n\n", contents)
+        self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=0\n\n", contents)
+
+    def test_build_index_one_reference_list_empty(self):
+        builder = GraphIndexBuilder(reference_lists=1)
+        stream = builder.finish()
+        contents = stream.read()
+        self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=1\n\n", contents)
 
 
 class TestGraphIndex(TestCaseWithMemoryTransport):
@@ -36,7 +42,7 @@
         builder = GraphIndexBuilder()
         stream = builder.finish()
         trans = self.get_transport()
-        trans.put('index', stream.read())
+        trans.put_file('index', stream)
         return GraphIndex(trans, 'index')
 
     def test_iter_all_entries_empty(self):




More information about the bazaar-commits mailing list