/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2007-03-28 07:08:42 UTC
  • mfrom: (2380 +trunk)
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070328070842-r843houy668oxb9o
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
        self.assertFalse(wt.has_filename('b/c'))
199
199
        self.assertFalse(wt.has_filename('d'))
200
200
        wt.unlock()
 
201
 
 
202
    def test_commit_deleted_subtree_with_removed(self):
 
203
        wt = self.make_branch_and_tree('.')
 
204
        self.build_tree(['a', 'b/', 'b/c', 'd'])
 
205
        wt.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
 
206
        wt.commit('first')
 
207
        wt.remove('b/c')
 
208
        this_dir = self.get_transport()
 
209
        this_dir.delete_tree('b')
 
210
        wt.lock_write()
 
211
        wt.commit('commit deleted rename')
 
212
        self.assertTrue(wt.has_id('a-id'))
 
213
        self.assertFalse(wt.has_or_had_id('b-id'))
 
214
        self.assertFalse(wt.has_or_had_id('c-id'))
 
215
        self.assertTrue(wt.has_filename('a'))
 
216
        self.assertFalse(wt.has_filename('b'))
 
217
        self.assertFalse(wt.has_filename('b/c'))
 
218
        wt.unlock()
 
219
 
 
220
    def test_commit_move_new(self):
 
221
        wt = self.make_branch_and_tree('first')
 
222
        wt.commit('first')
 
223
        wt2 = wt.bzrdir.sprout('second').open_workingtree()
 
224
        self.build_tree(['second/name1'])
 
225
        wt2.add('name1', 'name1-id')
 
226
        wt2.commit('second')
 
227
        wt.merge_from_branch(wt2.branch)
 
228
        wt.rename_one('name1', 'name2')
 
229
        wt.commit('third')
 
230
        wt.path2id('name1-id')
 
231
 
 
232
    def test_nested_commit(self):
 
233
        """Commit in multiply-nested trees"""
 
234
        tree = self.make_branch_and_tree('.')
 
235
        if not tree.supports_tree_reference():
 
236
            # inapplicable test.
 
237
            return
 
238
        subtree = self.make_branch_and_tree('subtree')
 
239
        subsubtree = self.make_branch_and_tree('subtree/subtree')
 
240
        subtree.add(['subtree'])
 
241
        tree.add(['subtree'])
 
242
        # use allow_pointless=False to ensure that the deepest tree, which
 
243
        # has no commits made to it, does not get a pointless commit.
 
244
        rev_id = tree.commit('added reference', allow_pointless=False)
 
245
        tree.lock_read()
 
246
        self.addCleanup(tree.unlock)
 
247
        # the deepest subtree has not changed, so no commit should take place.
 
248
        self.assertEqual(None, subsubtree.last_revision())
 
249
        # the intermediate tree should have committed a pointer to the current
 
250
        # subtree revision.
 
251
        sub_basis = subtree.basis_tree()
 
252
        sub_basis.lock_read()
 
253
        self.addCleanup(sub_basis.unlock)
 
254
        self.assertEqual(subsubtree.last_revision(),
 
255
            sub_basis.get_reference_revision(sub_basis.path2id('subtree')))
 
256
        # the intermediate tree has changed, so should have had a commit
 
257
        # take place.
 
258
        self.assertNotEqual(None, subtree.last_revision())
 
259
        # the outer tree should have committed a pointer to the current
 
260
        # subtree revision.
 
261
        basis = tree.basis_tree()
 
262
        basis.lock_read()
 
263
        self.addCleanup(basis.unlock)
 
264
        self.assertEqual(subtree.last_revision(),
 
265
            basis.get_reference_revision(basis.path2id('subtree')))
 
266
        # the outer tree must have have changed too.
 
267
        self.assertNotEqual(None, rev_id)
201
268
        
 
269
    def test_nested_commit_second_commit_detects_changes(self):
 
270
        """Commit with a nested tree picks up the correct child revid."""
 
271
        tree = self.make_branch_and_tree('.')
 
272
        if not tree.supports_tree_reference():
 
273
            # inapplicable test.
 
274
            return
 
275
        subtree = self.make_branch_and_tree('subtree')
 
276
        tree.add(['subtree'])
 
277
        self.build_tree(['subtree/file'])
 
278
        subtree.add(['file'], ['file-id'])
 
279
        rev_id = tree.commit('added reference', allow_pointless=False)
 
280
        child_revid = subtree.last_revision()
 
281
        # now change the child tree
 
282
        self.build_tree_contents([('subtree/file', 'new-content')])
 
283
        # and commit in the parent should commit the child and grab its revid,
 
284
        # we test with allow_pointless=False here so that we are simulating
 
285
        # what users will see.
 
286
        rev_id2 = tree.commit('changed subtree only', allow_pointless=False)
 
287
        # the child tree has changed, so should have had a commit
 
288
        # take place.
 
289
        self.assertNotEqual(None, subtree.last_revision())
 
290
        self.assertNotEqual(child_revid, subtree.last_revision())
 
291
        # the outer tree should have committed a pointer to the current
 
292
        # subtree revision.
 
293
        basis = tree.basis_tree()
 
294
        basis.lock_read()
 
295
        self.addCleanup(basis.unlock)
 
296
        self.assertEqual(subtree.last_revision(),
 
297
            basis.get_reference_revision(basis.path2id('subtree')))
 
298
        self.assertNotEqual(rev_id, rev_id2)
 
299
 
202
300
 
203
301
class TestCommitProgress(TestCaseWithWorkingTree):
204
302