Rev 4801: Implement iter_all_entries. in http://bazaar.launchpad.net/~jameinel/bzr/chk-index

John Arbash Meinel john at arbash-meinel.com
Wed Oct 28 19:55:12 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/chk-index

------------------------------------------------------------
revno: 4801
revision-id: john at arbash-meinel.com-20091028195503-lzy0faa8op3z85yy
parent: john at arbash-meinel.com-20091028195226-rf8w9cjve29ourj9
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: chk-index
timestamp: Wed 2009-10-28 14:55:03 -0500
message:
  Implement iter_all_entries.
-------------- next part --------------
=== modified file 'bzrlib/chk_index.py'
--- a/bzrlib/chk_index.py	2009-10-28 19:52:26 +0000
+++ b/bzrlib/chk_index.py	2009-10-28 19:55:03 +0000
@@ -712,6 +712,13 @@
         to_key = self._bit_key_to_key
         return [to_key(bit_key) for bit_key in self._entries]
 
+    def iter_all_entries(self):
+        self._ensure_header()
+        self._read_all()
+        b_to_k = self._bit_key_to_key
+        for bit_key, value in self._entries.iteritems():
+            yield self, b_to_k(bit_key), value
+
     def iter_entries(self, keys):
         """See GraphIndex.iter_entries()"""
         self._ensure_header()
@@ -753,6 +760,7 @@
         """Read in all the entry records and store them in self._entries"""
         offsets = [idx for idx, info in enumerate(self._mini_index)
                         if not info[2]]
+        # TODO: make this a no-op if offsets is an empty list
         self._read_entries(offsets)
 
     def _read_entries(self, indexes):

=== modified file 'bzrlib/tests/test_chk_index.py'
--- a/bzrlib/tests/test_chk_index.py	2009-10-28 19:52:26 +0000
+++ b/bzrlib/tests/test_chk_index.py	2009-10-28 19:55:03 +0000
@@ -824,3 +824,13 @@
                                  (index, k2, ((0, 1000), 10, 9)),
                                  (index, k3, ((0, 1000), 19, 9))]),
                          sorted(index.iter_entries([k1, k2, k3])))
+
+    def test_iter_all_entries(self):
+        index = self.make_index([(k1, 0, 1000, 0, 10),
+                                 (k2, 0, 1000, 10, 9),
+                                 (k3, 0, 1000, 19, 9),
+                                ])
+        self.assertEqual(sorted([(index, k1, ((0, 1000), 0, 10)),
+                                 (index, k2, ((0, 1000), 10, 9)),
+                                 (index, k3, ((0, 1000), 19, 9))]),
+                         sorted(index.iter_all_entries()))



More information about the bazaar-commits mailing list