Rev 3186: Allow all file ids for /, not just TREE_ROOT when the root is not versioned. in http://people.ubuntu.com/~robertc/baz2.0/inventory.journalled

Robert Collins robertc at robertcollins.net
Tue Jan 8 04:27:55 GMT 2008


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

------------------------------------------------------------
revno: 3186
revision-id:robertc at robertcollins.net-20080108042750-rj0fr05p4l8rcklq
parent: robertc at robertcollins.net-20080108042036-j5dgdue3u9vfvuas
committer: Robert Collins <robertc at robertcollins.net>
branch nick: inventory.journalled
timestamp: Tue 2008-01-08 15:27:50 +1100
message:
  Allow all file ids for /, not just TREE_ROOT when the root is not versioned.
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-08 04:20:36 +0000
+++ b/bzrlib/journalled_inventory.py	2008-01-08 04:27:50 +0000
@@ -207,9 +207,6 @@
             if utf8_path == '/' and not self.versioned_root:
                 # This is a double check as its done during parsing, but it
                 # seems worthwhile.
-                if file_id != 'TREE_ROOT':
-                    raise errors.BzrError(
-                        'file_id %s is not TREE_ROOT for /' % file_id)
                 if last_modified != NULL_REVISION:
                     raise errors.BzrError(
                         'Version present (%s) for / in %s' %
@@ -330,9 +327,6 @@
             last_modified = entry.revision
             # special cases for /
             if newpath_utf8 == '/' and not self._versioned_root:
-                if file_id != 'TREE_ROOT':
-                    raise errors.BzrError(
-                        'file_id %s is not TREE_ROOT for /' % file_id)
                 # discard any version and record NULL.
                 last_modified = NULL_REVISION
             if last_modified is None:
@@ -438,7 +432,7 @@
             by_id[file_id] = (newpath_utf8, file_id, parent_id,
                 last_modified, tuple(content.split('\x00')))
             if newpath_utf8 == '/' and not self._versioned_root:
-                if last_modified != 'null:' or file_id != 'TREE_ROOT':
+                if last_modified != 'null:':
                     raise errors.BzrError("Versioned root found: %r" % line)
             elif newpath_utf8 != 'None' and last_modified[-1] == ':':
                     raise errors.BzrError('special revisionid found: %r' % line)

=== modified file 'bzrlib/tests/test_journalled_inv.py'
--- a/bzrlib/tests/test_journalled_inv.py	2008-01-08 04:01:40 +0000
+++ b/bzrlib/tests/test_journalled_inv.py	2008-01-08 04:27:50 +0000
@@ -65,7 +65,7 @@
 parent: null:
 parent_validator: 
 version: entry-version
-/\x00TREE_ROOT\x00\x00null:\x00dir
+/\x00an-id\x00\x00null:\x00dir
 """
 
 reference_lines = """format: bzr journalled inventory v1 (bzr 1.2)
@@ -120,14 +120,14 @@
     def test_unversioned_root(self):
         old_inv = Inventory(None)
         new_inv = Inventory(None)
-        root = new_inv.make_entry('directory', '', None, 'TREE_ROOT')
+        root = new_inv.make_entry('directory', '', None, 'an-id')
         new_inv.add(root)
         delta = inventory.make_inv_delta(old_inv, new_inv)
         journal = journalled_inventory.InventoryJournal(versioned_root=False,
             tree_references=False)
         self.assertEqual((StringIO(root_only_unversioned).readlines(),
-            '3fccf5120c89399c7690e24b5647bbf55128e26b',
-            '3fccf5120c89399c7690e24b5647bbf55128e26b'),
+            '62d810853d3e60234f83106acf881d0da7dac4f5',
+            '62d810853d3e60234f83106acf881d0da7dac4f5'),
             journal.delta_to_lines(NULL_REVISION, "", 'entry-version', delta))
 
     def test_old_validator_stored_new_validator_returned(self):
@@ -171,28 +171,17 @@
     def test_nonrichroot_versioned_root_ignores_version(self):
         old_inv = Inventory(None)
         new_inv = Inventory(None)
-        root = new_inv.make_entry('directory', '', None, 'TREE_ROOT')
+        root = new_inv.make_entry('directory', '', None, 'an-id')
         root.revision = 'a at e\xc3\xa5ample.com--2004'
         new_inv.add(root)
         delta = inventory.make_inv_delta(old_inv, new_inv)
         journal = journalled_inventory.InventoryJournal(versioned_root=False,
             tree_references=True)
         self.assertEqual((StringIO(root_only_unversioned).readlines(),
-            '3fccf5120c89399c7690e24b5647bbf55128e26b',
-            '3fccf5120c89399c7690e24b5647bbf55128e26b'),
+            '62d810853d3e60234f83106acf881d0da7dac4f5',
+            '62d810853d3e60234f83106acf881d0da7dac4f5'),
             journal.delta_to_lines(NULL_REVISION, "", 'entry-version', delta))
 
-    def test_nonrichroot_non_TREE_ROOT_id_errors(self):
-        old_inv = Inventory(None)
-        new_inv = Inventory(None)
-        root = new_inv.make_entry('directory', '', None, 'my-rich-root-id')
-        new_inv.add(root)
-        delta = inventory.make_inv_delta(old_inv, new_inv)
-        journal = journalled_inventory.InventoryJournal(versioned_root=False,
-            tree_references=True)
-        self.assertRaises(errors.BzrError,
-            journal.delta_to_lines, NULL_REVISION, "", 'entry-version', delta)
-
     def test_unknown_kind_errors(self):
         old_inv = Inventory(None)
         new_inv = Inventory(None)
@@ -329,13 +318,13 @@
         self.assertEqual('entry-version', journal_entry.version)
 
     def test_parse_special_revid_not_valid_last_mod(self):
-        journal = journalled_inventory.InventoryJournal(versioned_root=False,
+        journal = journalled_inventory.InventoryJournal(versioned_root=True,
             tree_references=True)
         root_only_lines = """format: bzr journalled inventory v1 (bzr 1.2)
 parent: null:
 parent_validator: 
 version: null:
-/\x00TREE_ROOT\x00\x00null:\x00dir\x00\x00
+/\x00TREE_ROOT\x00\x00null:\x00dir
 """
         self.assertRaises(errors.BzrError,
             journal.parse_text_bytes, root_only_lines)
@@ -352,18 +341,6 @@
         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.2)
-parent: null:
-parent_validator: 
-version: 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)



More information about the bazaar-commits mailing list