Rev 2612: Empty keys are invalid. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Fri Jul 13 08:28:24 BST 2007


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

------------------------------------------------------------
revno: 2612
revision-id: robertc at robertcollins.net-20070713072818-5db95luqwe9palp5
parent: robertc at robertcollins.net-20070713072242-vgf4mkayfyjk6zy0
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 17:28:18 +1000
message:
  Empty keys are invalid.
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 07:22:42 +0000
+++ b/bzrlib/index.py	2007-07-13 07:28:18 +0000
@@ -66,7 +66,7 @@
         :param value: The value to associate with the key. It may be any
             bytes as long as it does not contain \0 or \n.
         """
-        if _whitespace_re.search(key) is not None:
+        if not key or _whitespace_re.search(key) is not None:
             raise errors.BadIndexKey(key)
         if _newline_null_re.search(value) is not None:
             raise errors.BadIndexValue(value)

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2007-07-13 07:22:42 +0000
+++ b/bzrlib/tests/test_index.py	2007-07-13 07:28:18 +0000
@@ -89,6 +89,8 @@
         for bad_char in '\t\n\x0b\x0c\r\x00 ':
             self.assertRaises(errors.BadIndexKey, builder.add_node,
                 'a%skey' % bad_char, (), 'data')
+        self.assertRaises(errors.BadIndexKey, builder.add_node,
+                '', (), 'data')
 
     def test_add_node_bad_data(self):
         builder = GraphIndexBuilder()




More information about the bazaar-commits mailing list