Rev 2873: * ``CommitBuilder.record_entry_contents`` now requires the root entry of a in http://people.ubuntu.com/~robertc/baz2.0/commit-builder

Robert Collins robertc at robertcollins.net
Fri Sep 28 02:21:20 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/commit-builder

------------------------------------------------------------
revno: 2873
revision-id: robertc at robertcollins.net-20070928012059-sbuwqzv68dlbb9z9
parent: robertc at robertcollins.net-20070928005033-k2aj7takjzzfo3vn
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-builder
timestamp: Fri 2007-09-28 11:20:59 +1000
message:
  * ``CommitBuilder.record_entry_contents`` now requires the root entry of a
    tree be supplied to it, previously failing to do so would trigger a
    deprecation warning. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
=== modified file 'NEWS'
--- a/NEWS	2007-09-28 00:50:33 +0000
+++ b/NEWS	2007-09-28 01:20:59 +0000
@@ -111,6 +111,10 @@
 
   API BREAKS:
 
+   * ``CommitBuilder.record_entry_contents`` now requires the root entry of a
+     tree be supplied to it, previously failing to do so would trigger a
+     deprecation warning. (Robert Collins)
+
    * ``KnitVersionedFile.add*`` will no longer cache added records even when
      enable_cache() has been called - the caching feature is now exclusively for
      reading existing data. (Robert Collins)

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2007-09-28 00:50:33 +0000
+++ b/bzrlib/errors.py	2007-09-28 01:20:59 +0000
@@ -254,6 +254,12 @@
         self.revision_id = revision_id
 
 
+class RootMissing(InternalBzrError):
+
+    _fmt = ("The root entry of a tree must be the first entry supplied to "
+        "record_entry_contents.")
+
+
 class NoHelpTopic(BzrError):
 
     _fmt = ("No help could be found for '%(topic)s'. "

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-09-25 03:36:29 +0000
+++ b/bzrlib/repository.py	2007-09-28 01:20:59 +0000
@@ -194,18 +194,10 @@
             commit.
         :param tree: The tree that is being committed.
         """
-        if ie.parent_id is not None:
-            # if ie is not root, add a root automatically.
-            symbol_versioning.warn('Root entry should be supplied to'
-                ' record_entry_contents, as of bzr 0.10.',
-                 DeprecationWarning, stacklevel=2)
-            self.record_entry_contents(tree.inventory.root.copy(), parent_invs,
-                                       '', tree)
-        else:
-            # In this revision format, root entries have no knit or weave When
-            # serializing out to disk and back in root.revision is always
-            # _new_revision_id
-            ie.revision = self._new_revision_id
+        # In this revision format, root entries have no knit or weave When
+        # serializing out to disk and back in root.revision is always
+        # _new_revision_id
+        ie.revision = self._new_revision_id
 
     def record_entry_contents(self, ie, parent_invs, path, tree):
         """Record the content of ie from tree into the commit if needed.
@@ -223,6 +215,8 @@
             will not return True.)
         """
         if self.new_inventory.root is None:
+            if ie.parent_id is not None:
+                raise errors.RootMissing()
             self._check_root(ie, parent_invs, tree)
         self.new_inventory.add(ie)
 
@@ -332,8 +326,6 @@
             commit.
         :param tree: The tree that is being committed.
         """
-        # ie must be root for this builder
-        assert ie.parent_id is None
 
 
 ######################################################################

=== modified file 'bzrlib/tests/repository_implementations/test_commit_builder.py'
--- a/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-09-23 20:25:33 +0000
+++ b/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-09-28 01:20:59 +0000
@@ -120,22 +120,17 @@
         self.assertEqual(revision_id,
             tree.branch.repository.get_inventory(revision_id).revision_id)
 
-    def test_commit_without_root(self):
-        """This should cause a deprecation warning, not an assertion failure"""
+    def test_commit_without_root_errors(self):
         tree = self.make_branch_and_tree(".")
         tree.lock_write()
         try:
-            if tree.branch.repository.supports_rich_root():
-                raise tests.TestSkipped('Format requires root')
             self.build_tree(['foo'])
             tree.add('foo', 'foo-id')
             entry = tree.inventory['foo-id']
             builder = tree.branch.get_commit_builder([])
-            self.callDeprecated(['Root entry should be supplied to'
-                ' record_entry_contents, as of bzr 0.10.'],
+            self.assertRaises(errors.RootMissing,
                 builder.record_entry_contents, entry, [], 'foo', tree)
-            builder.finish_inventory()
-            rev_id = builder.commit('foo bar')
+            builder.abort()
         finally:
             tree.unlock()
     



More information about the bazaar-commits mailing list