/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 breezy/tests/per_workingtree/test_commit.py

  • Committer: Jelmer Vernooij
  • Date: 2019-12-23 01:39:21 UTC
  • mfrom: (7424 work)
  • mto: This revision was merged to the branch mainline in revision 7425.
  • Revision ID: jelmer@jelmer.uk-20191223013921-2kzd0wlcoylgxksk
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        osutils.rmtree('a/dir')
54
54
        tree_a.commit('autoremoved')
55
55
 
56
 
        tree_a.lock_read()
57
 
        try:
58
 
            root_id = tree_a.get_root_id()
 
56
        with tree_a.lock_read():
 
57
            root_id = tree_a.path2id('')
59
58
            paths = [(path, ie.file_id)
60
59
                     for path, ie in tree_a.iter_entries_by_dir()]
61
 
        finally:
62
 
            tree_a.unlock()
63
60
        # The only paths left should be the root
64
61
        self.assertEqual([('', root_id)], paths)
65
62
 
158
155
        tree.lock_read()
159
156
        self.addCleanup(tree.unlock)
160
157
        changes = list(tree.iter_changes(tree.basis_tree()))
161
 
        self.assertEqual([(None, 'b'), (None, 'c')], [c[1] for c in changes])
 
158
        self.assertEqual([(None, 'b'), (None, 'c')], [c.path for c in changes])
162
159
 
163
160
    def test_commit_exclude_subtree_of_selected(self):
164
161
        tree = self.make_branch_and_tree('.')
170
167
        self.addCleanup(tree.unlock)
171
168
        changes = list(tree.iter_changes(tree.basis_tree()))
172
169
        self.assertEqual(1, len(changes))
173
 
        self.assertEqual((None, 'a/b'), changes[0][1])
 
170
        self.assertEqual((None, 'a/b'), changes[0].path)
174
171
 
175
172
    def test_commit_sets_last_revision(self):
176
173
        tree = self.make_branch_and_tree('tree')
217
214
    def test_commit_aborted_does_not_apply_automatic_changes_bug_282402(self):
218
215
        wt = self.make_branch_and_tree('.')
219
216
        wt.add(['a'], None, ['file'])
220
 
        a_id = wt.path2id('a')
221
 
        self.assertEqual('a', wt.id2path(a_id))
 
217
        self.assertTrue(wt.is_versioned('a'))
 
218
        if wt.supports_setting_file_ids():
 
219
            a_id = wt.path2id('a')
 
220
            self.assertEqual('a', wt.id2path(a_id))
222
221
 
223
222
        def fail_message(obj):
224
223
            raise errors.BzrCommandError("empty commit message")
225
224
        self.assertRaises(errors.BzrCommandError, wt.commit,
226
225
                          message_callback=fail_message)
227
 
        self.assertEqual('a', wt.id2path(a_id))
 
226
        self.assertTrue(wt.is_versioned('a'))
 
227
        if wt.supports_setting_file_ids():
 
228
            self.assertEqual('a', wt.id2path(a_id))
228
229
 
229
230
    def test_local_commit_ignores_master(self):
230
231
        # a --local commit does not require access to the master branch
311
312
        # a present on disk. After commit b-id, c-id and d-id should be
312
313
        # missing from the inventory, within the same tree transaction.
313
314
        wt.commit('commit stuff')
314
 
        self.assertTrue(wt.has_id(a_id))
315
 
        self.assertFalse(wt.has_or_had_id(b_id))
316
 
        self.assertFalse(wt.has_or_had_id(c_id))
317
 
        self.assertFalse(wt.has_or_had_id(d_id))
318
315
        self.assertTrue(wt.has_filename('a'))
319
316
        self.assertFalse(wt.has_filename('b'))
320
317
        self.assertFalse(wt.has_filename('b/c'))
323
320
        # the changes should have persisted to disk - reopen the workingtree
324
321
        # to be sure.
325
322
        wt = wt.controldir.open_workingtree()
326
 
        wt.lock_read()
327
 
        self.assertTrue(wt.has_id(a_id))
328
 
        self.assertFalse(wt.has_or_had_id(b_id))
329
 
        self.assertFalse(wt.has_or_had_id(c_id))
330
 
        self.assertFalse(wt.has_or_had_id(d_id))
331
 
        self.assertTrue(wt.has_filename('a'))
332
 
        self.assertFalse(wt.has_filename('b'))
333
 
        self.assertFalse(wt.has_filename('b/c'))
334
 
        self.assertFalse(wt.has_filename('d'))
335
 
        wt.unlock()
 
323
        with wt.lock_read():
 
324
            self.assertTrue(wt.has_filename('a'))
 
325
            self.assertFalse(wt.has_filename('b'))
 
326
            self.assertFalse(wt.has_filename('b/c'))
 
327
            self.assertFalse(wt.has_filename('d'))
336
328
 
337
329
    def test_commit_deleted_subtree_with_removed(self):
338
330
        wt = self.make_branch_and_tree('.')
345
337
        wt.remove('b/c')
346
338
        this_dir = wt.controldir.root_transport
347
339
        this_dir.delete_tree('b')
348
 
        wt.lock_write()
349
 
        wt.commit('commit deleted rename')
350
 
        self.assertTrue(wt.is_versioned('a'))
351
 
        self.assertFalse(wt.has_or_had_id(b_id))
352
 
        self.assertFalse(wt.has_or_had_id(c_id))
353
 
        self.assertTrue(wt.has_filename('a'))
354
 
        self.assertFalse(wt.has_filename('b'))
355
 
        self.assertFalse(wt.has_filename('b/c'))
356
 
        wt.unlock()
 
340
        with wt.lock_write():
 
341
            wt.commit('commit deleted rename')
 
342
            self.assertTrue(wt.is_versioned('a'))
 
343
            self.assertTrue(wt.has_filename('a'))
 
344
            self.assertFalse(wt.has_filename('b'))
 
345
            self.assertFalse(wt.has_filename('b/c'))
357
346
 
358
347
    def test_commit_move_new(self):
359
348
        wt = self.make_branch_and_tree('first')