Rev 5229: (abentley) CommitBuilder refuses to commit trees with no root. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 13 19:53:03 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5229 [merge]
revision-id: pqm at pqm.ubuntu.com-20100513185258-xtx26u4bsjyhat1n
parent: pqm at pqm.ubuntu.com-20100513173255-x3kt3mczwhphdm5y
parent: aaron at aaronbentley.com-20100511133131-e68bir2ul92ag4zs
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-05-13 19:52:58 +0100
message:
  (abentley) CommitBuilder refuses to commit trees with no root.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/repofmt/groupcompress_repo.py repofmt.py-20080715094215-wp1qfvoo7093c8qr-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'NEWS'
--- a/NEWS	2010-05-11 17:22:12 +0000
+++ b/NEWS	2010-05-13 18:52:58 +0000
@@ -86,6 +86,9 @@
 * ``bzr selftest`` should not use ui.note() since it's not unicode safe.
   (Vincent Ladeuil, #563997)
 
+* CommitBuilder refuses to create revisions whose trees have no root.
+  (Aaron Bentley)
+
 * Don't mention --no-strict when we just issue the warning about unclean trees.
   (Vincent Ladeuil, #401599)
 

=== modified file 'bzrlib/repofmt/groupcompress_repo.py'
--- a/bzrlib/repofmt/groupcompress_repo.py	2010-05-11 10:45:26 +0000
+++ b/bzrlib/repofmt/groupcompress_repo.py	2010-05-13 18:52:58 +0000
@@ -862,6 +862,8 @@
         if basis_inv is None:
             if basis_revision_id == _mod_revision.NULL_REVISION:
                 new_inv = self._create_inv_from_null(delta, new_revision_id)
+                if new_inv.root_id is None:
+                    raise errors.RootMissing()
                 inv_lines = new_inv.to_lines()
                 return self._inventory_add_lines(new_revision_id, parents,
                     inv_lines, check_content=False), new_inv

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2010-05-11 08:44:59 +0000
+++ b/bzrlib/repository.py	2010-05-13 18:52:58 +0000
@@ -288,8 +288,8 @@
 
         :param tree: The tree which is being committed.
         """
-        # NB: if there are no parents then this method is not called, so no
-        # need to guard on parents having length.
+        if len(self.parents) == 0:
+            raise errors.RootMissing()
         entry = entry_factory['directory'](tree.path2id(''), '',
             None)
         entry.revision = self._new_revision_id
@@ -1045,7 +1045,7 @@
                 " id and insertion revid (%r, %r)"
                 % (inv.revision_id, revision_id))
         if inv.root is None:
-            raise AssertionError()
+            raise errors.RootMissing()
         return self._add_inventory_checked(revision_id, inv, parents)
 
     def _add_inventory_checked(self, revision_id, inv, parents):

=== modified file 'bzrlib/tests/per_repository/test_commit_builder.py'
--- a/bzrlib/tests/per_repository/test_commit_builder.py	2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/per_repository/test_commit_builder.py	2010-05-11 13:31:31 +0000
@@ -193,6 +193,23 @@
         self.assertEqual(revision_id,
             tree.branch.repository.get_inventory(revision_id).revision_id)
 
+    def test_commit_without_root_errors(self):
+        tree = self.make_branch_and_tree(".")
+        tree.lock_write()
+        try:
+            builder = tree.branch.get_commit_builder([])
+            def do_commit():
+                try:
+                    list(builder.record_iter_changes(
+                        tree, tree.last_revision(), []))
+                    builder.finish_inventory()
+                except:
+                    builder.abort()
+                    raise
+            self.assertRaises(errors.RootMissing, do_commit)
+        finally:
+            tree.unlock()
+
     def test_commit_without_root_or_record_iter_changes_errors(self):
         tree = self.make_branch_and_tree(".")
         tree.lock_write()

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2010-05-11 08:44:59 +0000
+++ b/bzrlib/tests/test_remote.py	2010-05-13 18:52:58 +0000
@@ -2257,6 +2257,7 @@
         self.setup_smart_server_with_call_log()
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
+        tree.add('')
         rev1 = tree.commit('First')
         rev2 = tree.commit('Second')
         tree.unlock()




More information about the bazaar-commits mailing list