Rev 3796: CombinedGraphIndex.validate() will now reload. in http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/pack_retry_153786

John Arbash Meinel john at arbash-meinel.com
Thu Oct 23 21:54:12 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/pack_retry_153786

------------------------------------------------------------
revno: 3796
revision-id: john at arbash-meinel.com-20081023205350-ynduycv3bh5qsup3
parent: john at arbash-meinel.com-20081023205058-z80mz4hp6o25v63w
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pack_retry_153786
timestamp: Thu 2008-10-23 15:53:50 -0500
message:
  CombinedGraphIndex.validate() will now reload.
-------------- next part --------------
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2008-10-23 20:50:58 +0000
+++ b/bzrlib/index.py	2008-10-23 20:53:50 +0000
@@ -1274,8 +1274,13 @@
 
     def validate(self):
         """Validate that everything in the index can be accessed."""
-        for index in self._indices:
-            index.validate()
+        while True:
+            try:
+                for index in self._indices:
+                    index.validate()
+                return
+            except errors.NoSuchFile:
+                self._reload_or_raise()
 
 
 class InMemoryGraphIndex(GraphIndexBuilder):

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2008-10-23 20:50:58 +0000
+++ b/bzrlib/tests/test_index.py	2008-10-23 20:53:50 +0000
@@ -1214,6 +1214,25 @@
         self.assertListRaises(errors.NoSuchFile, index.iter_entries_prefix,
                                                  [('1',)])
 
+    def test_validate_reloads(self):
+        index, reload_counter = self.make_combined_index_with_missing()
+        index.validate()
+        self.assertEqual([1, 1, 0], reload_counter)
+
+    def test_validate_reloads_midway(self):
+        index, reload_counter = self.make_combined_index_with_missing(['2'])
+        index.validate()
+
+    def test_validate_no_reload(self):
+        index, reload_counter = self.make_combined_index_with_missing()
+        index._reload_func = None
+        self.assertRaises(errors.NoSuchFile, index.validate)
+
+    def test_validate_reloads_and_fails(self):
+        index, reload_counter = self.make_combined_index_with_missing(
+                                    ['1', '2', '3'])
+        self.assertRaises(errors.NoSuchFile, index.validate)
+
 
 class TestInMemoryGraphIndex(TestCaseWithMemoryTransport):
 



More information about the bazaar-commits mailing list