~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_commit.py

  • Committer: Robert Collins
  • Date: 2007-03-06 10:51:27 UTC
  • mto: (2321.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070306105127-tdec4zgv1tkfgi1d
Fix failing detection of changes restricted to subtrees causing spurious pointless commit errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
250
250
        # the outer tree must have have changed too.
251
251
        self.assertNotEqual(None, rev_id)
252
252
        
 
253
    def test_nested_commit_second_commit_detects_changes(self):
 
254
        """Commit with a nested tree picks up the correct child revid."""
 
255
        tree = self.make_branch_and_tree('.')
 
256
        if not tree.supports_tree_reference():
 
257
            # inapplicable test.
 
258
            return
 
259
        subtree = self.make_branch_and_tree('subtree')
 
260
        tree.add(['subtree'])
 
261
        self.build_tree(['subtree/file'])
 
262
        subtree.add(['file'], ['file-id'])
 
263
        rev_id = tree.commit('added reference', allow_pointless=False)
 
264
        child_revid = subtree.last_revision()
 
265
        # now change the child tree
 
266
        self.build_tree_contents([('subtree/file', 'new-content')])
 
267
        # and commit in the parent should commit the child and grab its revid,
 
268
        # we test with allow_pointless=False here so that we are simulating
 
269
        # what users will see.
 
270
        rev_id2 = tree.commit('changed subtree only', allow_pointless=False)
 
271
        # the child tree has changed, so should have had a commit
 
272
        # take place.
 
273
        self.assertNotEqual(None, subtree.last_revision())
 
274
        self.assertNotEqual(child_revid, subtree.last_revision())
 
275
        # the outer tree should have committed a pointer to the current
 
276
        # subtree revision.
 
277
        basis = tree.basis_tree()
 
278
        basis.lock_read()
 
279
        self.addCleanup(basis.unlock)
 
280
        self.assertEqual(subtree.last_revision(),
 
281
            basis.get_reference_revision(
 
282
                basis.inventory[basis.path2id('subtree')]))
 
283
        self.assertNotEqual(rev_id, rev_id2)
 
284
 
253
285
 
254
286
class TestCommitProgress(TestCaseWithWorkingTree):
255
287