Rev 2600: Empty files should validate ok. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Thu Jul 12 15:44:13 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2600
revision-id: robertc at robertcollins.net-20070712144410-0ucqo377rxnoc7wu
parent: robertc at robertcollins.net-20070712140534-fpo7n43occzqixe7
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 00:44:10 +1000
message:
Empty files should validate ok.
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 14:05:34 +0000
+++ b/bzrlib/index.py 2007-07-12 14:44:10 +0000
@@ -79,6 +79,13 @@
yield None
raise errors.MissingKey(self, keys[0])
+ def _signature(self):
+ """The file signature for this index type."""
+ return _SIGNATURE
+
def validate(self):
"""Validate that everything in the index can be accessed."""
- raise errors.BadIndexFormatSignature(self._name, GraphIndex)
+ stream = self._transport.get(self._name)
+ signature = stream.read(len(self._signature()))
+ if not signature == self._signature():
+ raise errors.BadIndexFormatSignature(self._name, GraphIndex)
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2007-07-12 14:05:34 +0000
+++ b/bzrlib/tests/test_index.py 2007-07-12 14:44:10 +0000
@@ -63,3 +63,7 @@
trans.put_bytes('name', "not an index\n")
index = GraphIndex(trans, 'name')
self.assertRaises(errors.BadIndexFormatSignature, index.validate)
+
+ def test_validate_empty(self):
+ index = self.make_index()
+ index.validate()
More information about the bazaar-commits
mailing list