Rev 2475: Fix failing detection of changes restricted to subtrees causing spurious pointless commit errors. in http://bazaar.launchpad.net/~bzr/bzr/dirstate

Robert Collins robertc at robertcollins.net
Tue Mar 6 10:52:30 GMT 2007


At http://bazaar.launchpad.net/~bzr/bzr/dirstate

------------------------------------------------------------
revno: 2475
revision-id: robertc at robertcollins.net-20070306105127-tdec4zgv1tkfgi1d
parent: mbp at sourcefrog.net-20070306104738-ua4ifiix8zuvhv87
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate.dogfood
timestamp: Tue 2007-03-06 21:51:27 +1100
message:
  Fix failing detection of changes restricted to subtrees causing spurious pointless commit errors.
modified:
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
  bzrlib/tests/workingtree_implementations/test_commit.py test_commit.py-20060421013633-1610ec2331c8190f
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2007-03-06 10:29:01 +0000
+++ b/bzrlib/commit.py	2007-03-06 10:51:27 +0000
@@ -412,6 +412,7 @@
                     and (this.parent_id == other.parent_id)
                     and (this.kind == other.kind)
                     and (this.executable == other.executable)
+                    and (this.reference_revision == other.reference_revision)
                     )
         if not ie_equal_no_revision(new_root_ie, basis_root_ie):
             return True

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2007-03-05 04:55:34 +0000
+++ b/bzrlib/inventory.py	2007-03-06 10:51:27 +0000
@@ -297,6 +297,7 @@
         self.text_id = text_id
         self.parent_id = parent_id
         self.symlink_target = None
+        self.reference_revision = None
 
     def kind_character(self):
         """Return a short kind indicator useful for appending to names."""
@@ -469,6 +470,7 @@
                 and (self.kind == other.kind)
                 and (self.revision == other.revision)
                 and (self.executable == other.executable)
+                and (self.reference_revision == other.reference_revision)
                 )
 
     def __ne__(self, other):
@@ -509,8 +511,8 @@
 class RootEntry(InventoryEntry):
 
     __slots__ = ['text_sha1', 'text_size', 'file_id', 'name', 'kind',
-                 'text_id', 'parent_id', 'children', 'executable', 
-                 'revision', 'symlink_target']
+                 'text_id', 'parent_id', 'children', 'executable',
+                 'revision', 'symlink_target', 'reference_revision']
 
     def _check(self, checker, rev_id, tree):
         """See InventoryEntry._check"""
@@ -538,8 +540,8 @@
     """A directory in an inventory."""
 
     __slots__ = ['text_sha1', 'text_size', 'file_id', 'name', 'kind',
-                 'text_id', 'parent_id', 'children', 'executable', 
-                 'revision', 'symlink_target']
+                 'text_id', 'parent_id', 'children', 'executable',
+                 'revision', 'symlink_target', 'reference_revision']
 
     def _check(self, checker, rev_id, tree):
         """See InventoryEntry._check"""
@@ -585,8 +587,8 @@
     """A file in an inventory."""
 
     __slots__ = ['text_sha1', 'text_size', 'file_id', 'name', 'kind',
-                 'text_id', 'parent_id', 'children', 'executable', 
-                 'revision', 'symlink_target']
+                 'text_id', 'parent_id', 'children', 'executable',
+                 'revision', 'symlink_target', 'reference_revision']
 
     def _check(self, checker, tree_revision_id, tree):
         """See InventoryEntry._check"""
@@ -733,8 +735,8 @@
     """A file in an inventory."""
 
     __slots__ = ['text_sha1', 'text_size', 'file_id', 'name', 'kind',
-                 'text_id', 'parent_id', 'children', 'executable', 
-                 'revision', 'symlink_target']
+                 'text_id', 'parent_id', 'children', 'executable',
+                 'revision', 'symlink_target', 'reference_revision']
 
     def _check(self, checker, rev_id, tree):
         """See InventoryEntry._check"""

=== modified file 'bzrlib/tests/workingtree_implementations/test_commit.py'
--- a/bzrlib/tests/workingtree_implementations/test_commit.py	2007-03-06 10:29:01 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_commit.py	2007-03-06 10:51:27 +0000
@@ -250,6 +250,38 @@
         # the outer tree must have have changed too.
         self.assertNotEqual(None, rev_id)
         
+    def test_nested_commit_second_commit_detects_changes(self):
+        """Commit with a nested tree picks up the correct child revid."""
+        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'])
+        self.build_tree(['subtree/file'])
+        subtree.add(['file'], ['file-id'])
+        rev_id = tree.commit('added reference', allow_pointless=False)
+        child_revid = subtree.last_revision()
+        # now change the child tree
+        self.build_tree_contents([('subtree/file', 'new-content')])
+        # and commit in the parent should commit the child and grab its revid,
+        # we test with allow_pointless=False here so that we are simulating
+        # what users will see.
+        rev_id2 = tree.commit('changed subtree only', allow_pointless=False)
+        # the child tree has changed, so should have had a commit
+        # take place.
+        self.assertNotEqual(None, subtree.last_revision())
+        self.assertNotEqual(child_revid, subtree.last_revision())
+        # the outer tree should have committed a pointer to the current
+        # subtree revision.
+        basis = tree.basis_tree()
+        basis.lock_read()
+        self.addCleanup(basis.unlock)
+        self.assertEqual(subtree.last_revision(),
+            basis.get_reference_revision(
+                basis.inventory[basis.path2id('subtree')]))
+        self.assertNotEqual(rev_id, rev_id2)
+
 
 class TestCommitProgress(TestCaseWithWorkingTree):
     



More information about the bazaar-commits mailing list