250
250
# the outer tree must have have changed too.
251
251
self.assertNotEqual(None, rev_id)
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():
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
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
277
basis = tree.basis_tree()
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)
254
286
class TestCommitProgress(TestCaseWithWorkingTree):