Rev 2827: Review feedback, and fix pointless commits with nested trees to raise PointlessCommit appropriately. in http://people.ubuntu.com/~robertc/baz2.0/in-review/record-entry-returns-status

Robert Collins robertc at robertcollins.net
Thu Sep 20 08:59:58 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/in-review/record-entry-returns-status

------------------------------------------------------------
revno: 2827
revision-id: robertc at robertcollins.net-20070920075948-6f32d46hr3oyw4zb
parent: robertc at robertcollins.net-20070920034311-lgjoomiumagdhksn
committer: Robert Collins <robertc at robertcollins.net>
branch nick: record-entry-returns-status
timestamp: Thu 2007-09-20 17:59:48 +1000
message:
  Review feedback, and fix pointless commits with nested trees to raise PointlessCommit appropriately.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/workingtree_implementations/test_commit.py test_commit.py-20060421013633-1610ec2331c8190f
=== modified file 'NEWS'
--- a/NEWS	2007-09-20 03:43:11 +0000
+++ b/NEWS	2007-09-20 07:59:48 +0000
@@ -18,7 +18,7 @@
 
    * Committing a change which is not a merge and does not change the number of
      files in the tree is faster by utilising the data about whether files are
-     changed to determine if a the tree is unchanged rather than recalculating
+     changed to determine if the tree is unchanged rather than recalculating
      it at the end of the commit process. (Robert Collins)
 
    * Inventory serialisation no longer double-sha's the content.

=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2007-09-20 03:43:11 +0000
+++ b/bzrlib/commit.py	2007-09-20 07:59:48 +0000
@@ -650,7 +650,7 @@
                     self.basis_tree):
                     self.entries_changed = True
 
-        # note that deletes have occured
+        # note that deletes have occurred
         if set(self.basis_inv._byid.keys()) - set(self.builder.new_inventory._byid.keys()):
             self.entries_deleted = True
         # Report what was deleted.
@@ -738,8 +738,6 @@
                 local=self.local, reporter=self.reporter)
         except errors.PointlessCommit:
             pass
-        else:
-            self.entries_changed = True
 
     def _record_entry(self, path, file_id, specific_files, kind, name,
             parent_id, definitely_changed, existing_ie=None,

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2007-09-04 03:53:07 +0000
+++ b/bzrlib/inventory.py	2007-09-20 07:59:48 +0000
@@ -879,6 +879,13 @@
     def _forget_tree_state(self):
         self.reference_revision = None 
 
+    def _unchanged(self, previous_ie):
+        """See InventoryEntry._unchanged."""
+        compatible = super(TreeReference, self)._unchanged(previous_ie)
+        if self.reference_revision != previous_ie.reference_revision:
+            compatible = False
+        return compatible
+
 
 class Inventory(object):
     """Inventory of versioned files in a tree.

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-09-20 03:43:11 +0000
+++ b/bzrlib/repository.py	2007-09-20 07:59:48 +0000
@@ -70,6 +70,8 @@
     
     # all clients should supply tree roots.
     record_root_entry = True
+    # the default CommitBuilder does not manage trees whose root is versioned.
+    _versioned_root = False
 
     def __init__(self, repository, parents, config, timestamp=None, 
                  timezone=None, committer=None, revprops=None, 
@@ -191,7 +193,6 @@
         :param parent_invs: The inventories of the parent revisions of the
             commit.
         :param tree: The tree that is being committed.
-        :return: True if the root entry is versioned properly.
         """
         if ie.parent_id is not None:
             # if ie is not root, add a root automatically.
@@ -205,7 +206,6 @@
             # serializing out to disk and back in root.revision is always
             # _new_revision_id
             ie.revision = self._new_revision_id
-        return False
 
     def record_entry_contents(self, ie, parent_invs, path, tree):
         """Record the content of ie from tree into the commit if needed.
@@ -223,7 +223,7 @@
             will not return True.)
         """
         if self.new_inventory.root is None:
-            self._versioned_root = self._check_root(ie, parent_invs, tree)
+            self._check_root(ie, parent_invs, tree)
         self.new_inventory.add(ie)
 
         # ie.revision is always None if the InventoryEntry is considered
@@ -321,6 +321,9 @@
 class RootCommitBuilder(CommitBuilder):
     """This commitbuilder actually records the root id"""
     
+    # the root entry gets versioned properly by this builder.
+    _versioned_root = False
+
     def _check_root(self, ie, parent_invs, tree):
         """Helper for record_entry_contents.
 
@@ -328,11 +331,9 @@
         :param parent_invs: The inventories of the parent revisions of the
             commit.
         :param tree: The tree that is being committed.
-        :return: True if the root entry is versioned properly.
         """
         # ie must be root for this builder
         assert ie.parent_id is None
-        return True
 
 
 ######################################################################

=== modified file 'bzrlib/tests/workingtree_implementations/test_commit.py'
--- a/bzrlib/tests/workingtree_implementations/test_commit.py	2007-08-27 08:38:37 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_commit.py	2007-09-20 07:59:48 +0000
@@ -90,14 +90,14 @@
 
     def test_commit_sets_last_revision(self):
         tree = self.make_branch_and_tree('tree')
-        committed_id = tree.commit('foo', rev_id='foo', allow_pointless=True)
+        committed_id = tree.commit('foo', rev_id='foo')
         self.assertEqual(['foo'], tree.get_parent_ids())
         # the commit should have returned the same id we asked for.
         self.assertEqual('foo', committed_id)
 
     def test_commit_returns_revision_id(self):
         tree = self.make_branch_and_tree('.')
-        committed_id = tree.commit('message', allow_pointless=True)
+        committed_id = tree.commit('message')
         self.assertTrue(tree.branch.repository.has_revision(committed_id))
         self.assertNotEqual(None, committed_id)
 
@@ -323,6 +323,22 @@
             basis.get_reference_revision(basis.path2id('subtree')))
         self.assertNotEqual(rev_id, rev_id2)
 
+    def test_nested_pointless_commits_are_pointless(self):
+        tree = self.make_branch_and_tree('.')
+        if not tree.supports_tree_reference():
+            # inapplicable test.
+            return
+        subtree = self.make_branch_and_tree('subtree')
+        tree.add(['subtree'])
+        # record the reference.
+        rev_id = tree.commit('added reference')
+        child_revid = subtree.last_revision()
+        # now do a no-op commit with allow_pointless=False
+        self.assertRaises(errors.PointlessCommit, tree.commit, '',
+            allow_pointless=False)
+        self.assertEqual(child_revid, subtree.last_revision())
+        self.assertEqual(rev_id, tree.last_revision())
+
 
 class TestCommitProgress(TestCaseWithWorkingTree):
     



More information about the bazaar-commits mailing list