210
210
wt.rename_one('name1', 'name2')
211
211
wt.commit('third')
212
212
wt.path2id('name1-id')
214
def test_nested_commit(self):
215
"""Commit in multiply-nested trees"""
216
tree = self.make_branch_and_tree('.')
217
if not tree.supports_tree_reference():
220
subtree = self.make_branch_and_tree('subtree')
221
subsubtree = self.make_branch_and_tree('subtree/subtree')
222
subtree.add(['subtree'])
223
tree.add(['subtree'])
224
# use allow_pointless=False to ensure that the deepest tree, which
225
# has no commits made to it, does not get a pointless commit.
226
rev_id = tree.commit('added reference', allow_pointless=False)
228
self.addCleanup(tree.unlock)
229
# the deepest subtree has not changed, so no commit should take place.
230
self.assertEqual(None, subsubtree.last_revision())
231
# the intermediate tree should have committed a pointer to the current
233
sub_basis = subtree.basis_tree()
234
sub_basis.lock_read()
235
self.addCleanup(sub_basis.unlock)
236
self.assertEqual(subsubtree.last_revision(),
237
sub_basis.get_reference_revision(
238
sub_basis.inventory[sub_basis.path2id('subtree')]))
239
# the intermediate tree has changed, so should have had a commit
241
self.assertNotEqual(None, subtree.last_revision())
242
# the outer tree should have committed a pointer to the current
244
basis = tree.basis_tree()
246
self.addCleanup(basis.unlock)
247
self.assertEqual(subtree.last_revision(),
248
basis.get_reference_revision(
249
basis.inventory[basis.path2id('subtree')]))
250
# the outer tree must have have changed too.
251
self.assertNotEqual(None, rev_id)
215
254
class TestCommitProgress(TestCaseWithWorkingTree):