Rev 3829: Add a bit more strictness to the formatting, update the test case. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/inv_ordering

John Arbash Meinel john at arbash-meinel.com
Thu Feb 19 17:38:48 GMT 2009


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/inv_ordering

------------------------------------------------------------
revno: 3829
revision-id: john at arbash-meinel.com-20090219173830-131mja9uk764p1wr
parent: john at arbash-meinel.com-20090218210302-iy40qwncs7tgfev6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: inv_ordering
timestamp: Thu 2009-02-19 11:38:30 -0600
message:
  Add a bit more strictness to the formatting, update the test case.
-------------- next part --------------
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2009-02-18 21:03:02 +0000
+++ b/bzrlib/inventory.py	2009-02-19 17:38:30 +0000
@@ -1519,9 +1519,17 @@
         if lines[0] != 'chkinventory:':
             raise ValueError("not a serialised CHKInventory: %r" % bytes)
         info = {}
+        allowed_keys = frozenset(['root_id', 'revision_id', 'search_key_name',
+                                  'parent_id_basename_to_file_id',
+                                  'id_to_entry'])
         for line in lines[1:]:
             key, value = line.split(': ', 1)
-            assert key not in info
+            if key not in allowed_keys:
+                raise errors.BzrError('Unknown key in inventory: %r\n%r'
+                                      % (key, bytes))
+            if key in info:
+                raise errors.BzrError('Duplicate key in inventory: %r\n%r'
+                                      % (key, bytes))
             info[key] = value
         revision_id = info['revision_id']
         root_id = info['root_id']

=== modified file 'bzrlib/tests/test_inv.py'
--- a/bzrlib/tests/test_inv.py	2009-02-18 15:07:23 +0000
+++ b/bzrlib/tests/test_inv.py	2009-02-19 17:38:30 +0000
@@ -255,10 +255,10 @@
         lines = chk_inv.to_lines()
         self.assertEqual([
             'chkinventory:\n',
-            'revision_id: foo\n',
-            'root_id: TREE_ROOT\n',
             'search_key_name: hash-16-way\n',
+            'root_id: TREE_ROOT\n',
             'parent_id_basename_to_file_id: sha1:eb23f0ad4b07f48e88c76d4c94292be57fb2785f\n',
+            'revision_id: foo\n',
             'id_to_entry: sha1:debfe920f1f10e7929260f0534ac9a24d7aabbb4\n',
             ], lines)
         chk_inv = CHKInventory.deserialise(chk_bytes, ''.join(lines), ('foo',))



More information about the bazaar-commits mailing list