Rev 2599: A validate that goes boom. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Thu Jul 12 15:05:37 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2599
revision-id: robertc at robertcollins.net-20070712140534-fpo7n43occzqixe7
parent: robertc at robertcollins.net-20070712135140-6y4vgazp2dsrz45b
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 00:05:34 +1000
message:
A validate that goes boom.
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_index.py test_index.py-20070712131115-lolkarso50vjr64s-2
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-07-12 13:43:39 +0000
+++ b/bzrlib/errors.py 2007-07-12 14:05:34 +0000
@@ -343,6 +343,16 @@
_fmt = "Error in command line options"
+class BadIndexFormatSignature(BzrError):
+
+ _fmt = "%(value)s is not an index of type %(_type)s."
+
+ def __init__(self, value, _type):
+ BzrError.__init__(self)
+ self.value = value
+ self._type = _type
+
+
class BadOptionValue(BzrError):
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2007-07-12 13:51:40 +0000
+++ b/bzrlib/index.py 2007-07-12 14:05:34 +0000
@@ -78,3 +78,7 @@
if False:
yield None
raise errors.MissingKey(self, keys[0])
+
+ def validate(self):
+ """Validate that everything in the index can be accessed."""
+ raise errors.BadIndexFormatSignature(self._name, GraphIndex)
=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py 2007-07-12 13:43:39 +0000
+++ b/bzrlib/tests/test_errors.py 2007-07-12 14:05:34 +0000
@@ -183,6 +183,10 @@
error = errors.ReadError(path)
self.assertEqualDiff("Error reading from u'a path'.", str(error))
+ def test_bad_index_format_signature(self):
+ error = errors.BadIndexFormatSignature("foo", "bar")
+ self.assertEqual("foo is not an index of type bar.",
+ str(error))
def test_bzrnewerror_is_deprecated(self):
class DeprecatedError(errors.BzrNewError):
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2007-07-12 13:51:40 +0000
+++ b/bzrlib/tests/test_index.py 2007-07-12 14:05:34 +0000
@@ -45,6 +45,11 @@
trans.put_file('index', stream)
return GraphIndex(trans, 'index')
+ def test_open_bad_index_no_error(self):
+ trans = self.get_transport()
+ trans.put_bytes('name', "not an index\n")
+ index = GraphIndex(trans, 'name')
+
def test_iter_all_entries_empty(self):
index = self.make_index()
self.assertEqual([], list(index.iter_all_entries()))
@@ -52,3 +57,9 @@
def test_iter_missing_entry_empty(self):
index = self.make_index()
self.assertRaises(errors.MissingKey, list, index.iter_entries(['a']))
+
+ def test_validate_bad_index_errors(self):
+ trans = self.get_transport()
+ trans.put_bytes('name', "not an index\n")
+ index = GraphIndex(trans, 'name')
+ self.assertRaises(errors.BadIndexFormatSignature, index.validate)
More information about the bazaar-commits
mailing list