Rev 2629: Add CombinedGraphIndex.insert_index. in http://people.ubuntu.com/~robertc/baz2.0/index

Robert Collins robertc at robertcollins.net
Sat Jul 14 07:07:04 BST 2007


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

------------------------------------------------------------
revno: 2629
revision-id: robertc at robertcollins.net-20070714060702-fnpyy4ogd1q8zzpt
parent: robertc at robertcollins.net-20070713200006-ollxheg4pu5m9wf1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: index
timestamp: Sat 2007-07-14 16:07:02 +1000
message:
  Add CombinedGraphIndex.insert_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-07-13 20:00:06 +0000
+++ b/bzrlib/index.py	2007-07-14 06:07:02 +0000
@@ -281,7 +281,15 @@
         :param indices: The indices to query for data.
         """
         self._indices = indices
-        
+
+    def insert_index(self, pos, index):
+        """Insert a new index in the list of indices to query.
+
+        :param pos: The position to insert the index.
+        :param index: The index to insert.
+        """
+        self._indices.insert(pos, index)
+
     def iter_all_entries(self):
         """Iterate over all keys within the index
 

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2007-07-13 20:00:06 +0000
+++ b/bzrlib/tests/test_index.py	2007-07-14 06:07:02 +0000
@@ -343,6 +343,12 @@
         index1 = GraphIndex(trans, 'missing')
         index = CombinedGraphIndex([index1])
 
+    def test_add_index(self):
+        index = CombinedGraphIndex([])
+        index1 = self.make_index('name', nodes=[('key', (), '')])
+        index.insert_index(0, index1)
+        self.assertEqual([('key', (), '')], list(index.iter_all_entries()))
+
     def test_iter_all_entries_empty(self):
         index = CombinedGraphIndex([])
         self.assertEqual([], list(index.iter_all_entries()))




More information about the bazaar-commits mailing list