Rev 3168: Root parsing parameterisation cases. in http://people.ubuntu.com/~robertc/baz2.0/inventory.journalled

Robert Collins robertc at robertcollins.net
Thu Jan 3 23:04:06 GMT 2008


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

------------------------------------------------------------
revno: 3168
revision-id:robertc at robertcollins.net-20080103230401-uq4j501h7v8lwuj5
parent: robertc at robertcollins.net-20080103224539-l3vrykn2ia1h23yt
committer: Robert Collins <robertc at robertcollins.net>
branch nick: inventory.journalled
timestamp: Fri 2008-01-04 10:04:01 +1100
message:
  Root parsing parameterisation cases.
modified:
  bzrlib/journalled_inventory.py journalled_inventory-20080103020931-0ht5n40kwc0p7fy1-1
  bzrlib/tests/test_journalled_inv.py test_journalled_inv.-20080103012121-ny2w9slze5jgty8i-1
=== modified file 'bzrlib/journalled_inventory.py'
--- a/bzrlib/journalled_inventory.py	2008-01-03 22:45:39 +0000
+++ b/bzrlib/journalled_inventory.py	2008-01-03 23:04:01 +0000
@@ -184,6 +184,12 @@
             parent_id = parent_id or None
             by_id[file_id] = (newpath_utf8, file_id, parent_id,
                 last_modified, tuple(content.split('\x00')))
+            if newpath_utf8 == '/':
+                if self._versioned_root and last_modified == 'null:':
+                    raise errors.BzrError('unversioned root found: %r' % line)
+                elif not self._versioned_root and (last_modified != 'null:' or 
+                    file_id != 'TREE_ROOT'):
+                    raise errors.BzrError("Versioned root found: %r" % line)
         if len(by_id) + 2 != len(lines):
             raise errors.BzrError(
                 "duplicate file id in journal entry %r" % lines)

=== modified file 'bzrlib/tests/test_journalled_inv.py'
--- a/bzrlib/tests/test_journalled_inv.py	2008-01-03 22:45:39 +0000
+++ b/bzrlib/tests/test_journalled_inv.py	2008-01-03 23:04:01 +0000
@@ -261,6 +261,32 @@
             },
             journal_entry.by_id)
 
+    def test_parse_versioned_root_versioned_disabled(self):
+        journal = journalled_inventory.InventoryJournal(versioned_root=False,
+            tree_references=True)
+        root_only_lines = """format: bzr journalled inventory v1 (bzr 1.1)
+parent: null:
+/\x00TREE_ROOT\x00\x00a at e\xe5ample.com--2004\x00dir\x00\x00
+"""
+        self.assertRaises(errors.BzrError,
+            journal.parse_text_bytes, root_only_lines)
+
+    def test_parse_unique_root_id_root_versioned_disabled(self):
+        journal = journalled_inventory.InventoryJournal(versioned_root=False,
+            tree_references=True)
+        root_only_lines = """format: bzr journalled inventory v1 (bzr 1.1)
+parent: null:
+/\x00an-id\x00\x00null:\x00dir\x00\x00
+"""
+        self.assertRaises(errors.BzrError,
+            journal.parse_text_bytes, root_only_lines)
+
+    def test_parse_unversioned_root_versioning_enabled(self):
+        journal = journalled_inventory.InventoryJournal(versioned_root=True,
+            tree_references=True)
+        self.assertRaises(errors.BzrError,
+            journal.parse_text_bytes, root_only_unversioned)
+
 
 class TestContent(TestCase):
 



More information about the bazaar-commits mailing list