~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:29:01 UTC
  • mto: (2321.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070306102901-y25mgksdvocjmib8
Make the nested tree commit smoke test be more rigourous.

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
        wt.rename_one('name1', 'name2')
211
211
        wt.commit('third')
212
212
        wt.path2id('name1-id')
 
213
 
 
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():
 
218
            # inapplicable test.
 
219
            return
 
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)
 
227
        tree.lock_read()
 
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
 
232
        # subtree revision.
 
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
 
240
        # take place.
 
241
        self.assertNotEqual(None, subtree.last_revision())
 
242
        # the outer tree should have committed a pointer to the current
 
243
        # subtree revision.
 
244
        basis = tree.basis_tree()
 
245
        basis.lock_read()
 
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)
213
252
        
214
253
 
215
254
class TestCommitProgress(TestCaseWithWorkingTree):