~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_remove.py

resolve conflicts against trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for interface conformance of 'WorkingTree.remove'"""
18
18
 
19
19
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
20
 
from bzrlib import errors, ignores, osutils
 
20
from bzrlib import ignores, osutils
21
21
 
22
22
class TestRemove(TestCaseWithWorkingTree):
23
23
    """Tests WorkingTree.remove"""
29
29
    def get_tree(self, files):
30
30
        tree = self.make_branch_and_tree('.')
31
31
        self.build_tree(files)
32
 
        self.failUnlessExists(files)
 
32
        self.assertPathExists(files)
33
33
        return tree
34
34
 
35
35
    def get_committed_tree(self, files, message="Committing"):
41
41
 
42
42
    def assertRemovedAndDeleted(self, files):
43
43
        self.assertNotInWorkingTree(files)
44
 
        self.failIfExists(files)
 
44
        self.assertPathDoesNotExist(files)
45
45
 
46
46
    def assertRemovedAndNotDeleted(self, files):
47
47
        self.assertNotInWorkingTree(files)
48
 
        self.failUnlessExists(files)
 
48
        self.assertPathExists(files)
49
49
 
50
50
    def test_remove_keep(self):
51
51
        """Check that files and directories are unversioned but not deleted."""
79
79
        self.assertInWorkingTree(TestRemove.files)
80
80
        tree.remove(TestRemove.files, keep_files=False)
81
81
        self.assertNotInWorkingTree(TestRemove.files)
82
 
        self.failUnlessExists(TestRemove.backup_files)
 
82
        self.assertPathExists(TestRemove.backup_files)
83
83
        tree._validate()
84
84
 
85
85
    def test_remove_changed_file(self):
89
89
        self.assertInWorkingTree('a')
90
90
        tree.remove('a', keep_files=False)
91
91
        self.assertNotInWorkingTree(TestRemove.files)
92
 
        self.failUnlessExists('a.~1~')
 
92
        self.assertPathExists('a.~1~')
93
93
        tree._validate()
94
94
 
95
95
    def test_remove_deleted_files(self):
98
98
        for f in TestRemove.rfiles:
99
99
            osutils.delete_any(f)
100
100
        self.assertInWorkingTree(TestRemove.files)
101
 
        self.failIfExists(TestRemove.files)
 
101
        self.assertPathDoesNotExist(TestRemove.files)
102
102
        tree.remove(TestRemove.files, keep_files=False)
103
103
        self.assertRemovedAndDeleted(TestRemove.files)
104
104
        tree._validate()
111
111
            tree.rename_one(f,f+'x')
112
112
        rfilesx = ['bx/cx', 'bx', 'ax', 'dx']
113
113
        self.assertInWorkingTree(rfilesx)
114
 
        self.failUnlessExists(rfilesx)
 
114
        self.assertPathExists(rfilesx)
115
115
 
116
116
        tree.remove(rfilesx, keep_files=False)
117
117
        self.assertRemovedAndDeleted(rfilesx)
127
127
        self.build_tree_contents([('ax','changed and renamed!'),
128
128
                                  ('bx/cx','changed and renamed!')])
129
129
        self.assertInWorkingTree(rfilesx)
130
 
        self.failUnlessExists(rfilesx)
 
130
        self.assertPathExists(rfilesx)
131
131
 
132
132
        tree.remove(rfilesx, keep_files=False)
133
133
        self.assertNotInWorkingTree(rfilesx)
134
 
        self.failUnlessExists(['bx.~1~/cx.~1~', 'bx.~1~', 'ax.~1~'])
135
 
        self.failIfExists('dx.~1~') # unchanged file
 
134
        self.assertPathExists(['bx.~1~/cx.~1~', 'bx.~1~', 'ax.~1~'])
 
135
        self.assertPathDoesNotExist('dx.~1~') # unchanged file
136
136
        tree._validate()
137
137
 
138
138
    def test_force_remove_changed_files(self):
143
143
 
144
144
        tree.remove(TestRemove.files, keep_files=False, force=True)
145
145
        self.assertRemovedAndDeleted(TestRemove.files)
146
 
        self.failIfExists(['a.~1~', 'b.~1~/', 'b.~1~/c', 'd.~1~/'])
 
146
        self.assertPathDoesNotExist(['a.~1~', 'b.~1~/', 'b.~1~/c', 'd.~1~/'])
147
147
        tree._validate()
148
148
 
149
149
    def test_remove_unknown_files(self):
151
151
        tree = self.get_tree(TestRemove.files)
152
152
        tree.remove(TestRemove.files, keep_files=False)
153
153
        self.assertRemovedAndDeleted(TestRemove.files)
154
 
        self.failUnlessExists(TestRemove.backup_files)
 
154
        self.assertPathExists(TestRemove.backup_files)
155
155
        tree._validate()
156
156
 
157
157
    def test_remove_nonexisting_files(self):
206
206
 
207
207
        tree.remove(files, keep_files=False)
208
208
        self.assertNotInWorkingTree(files)
209
 
        self.failUnlessExists('an_ignored_file.~1~')
 
209
        self.assertPathExists('an_ignored_file.~1~')
210
210
        tree._validate()
211
211
 
212
212
    def test_dont_remove_directory_with_unknowns(self):
216
216
 
217
217
        self.build_tree(['a/unknown_file'])
218
218
        tree.remove('a', keep_files=False)
219
 
        self.failUnlessExists('a.~1~/unknown_file')
 
219
        self.assertPathExists('a.~1~/unknown_file')
220
220
 
221
221
        self.build_tree(['b/unknown_directory'])
222
222
        tree.remove('b', keep_files=False)
223
 
        self.failUnlessExists('b.~1~/unknown_directory')
 
223
        self.assertPathExists('b.~1~/unknown_directory')
224
224
 
225
225
        self.build_tree(['c/c/unknown_file'])
226
226
        tree.remove('c/c', keep_files=False)
227
 
        self.failUnlessExists('c/c.~1~/unknown_file')
 
227
        self.assertPathExists('c/c.~1~/unknown_file')
228
228
 
229
229
        tree.remove('c', keep_files=False)
230
 
        self.failUnlessExists('c.~1~/')
 
230
        self.assertPathExists('c.~1~/')
231
231
 
232
232
        self.assertNotInWorkingTree(directories)
233
233
        tree._validate()
242
242
        self.build_tree(other_files)
243
243
 
244
244
        self.assertInWorkingTree(files)
245
 
        self.failUnlessExists(files)
 
245
        self.assertPathExists(files)
246
246
 
247
247
        tree.remove('b', keep_files=False, force=True)
248
248
 
257
257
        self.build_tree_contents([('b/c', "some other new content!")])
258
258
 
259
259
        tree.remove('b', keep_files=False)
260
 
        self.failUnlessExists('b.~1~/c.~1~')
 
260
        self.assertPathExists('b.~1~/c.~1~')
261
261
        self.assertNotInWorkingTree(files)
262
262
 
263
263
    def test_remove_force_directory_with_changed_file(self):
281
281
        tree.rename_one('somedir/file', 'moved-file')
282
282
        tree.remove('somedir', keep_files=False)
283
283
        self.assertNotInWorkingTree('somedir')
284
 
        self.failIfExists('somedir')
 
284
        self.assertPathDoesNotExist('somedir')
285
285
        self.assertInWorkingTree('moved-file')
286
 
        self.failUnlessExists('moved-file')
 
286
        self.assertPathExists('moved-file')
287
287
 
288
288
    def test_remove_directory_with_renames(self):
289
289
        """Delete directory with renames in or out."""
298
298
        moved_files = ['b/file', 'b/directory/']
299
299
        self.assertRemovedAndDeleted(files_to_move)
300
300
        self.assertInWorkingTree(moved_files)
301
 
        self.failUnlessExists(moved_files)
 
301
        self.assertPathExists(moved_files)
302
302
 
303
303
        # check if it works with renames out
304
304
        tree.remove('a', keep_files=False)
315
315
        tree.add(['dir', 'dir/file'])
316
316
        tree.commit('add file')
317
317
        tree.remove('dir/', keep_files=False)
318
 
        self.failIfExists('tree/dir/file')
 
318
        self.assertPathDoesNotExist('tree/dir/file')
319
319
        self.assertNotInWorkingTree('tree/dir/file', 'tree')
320
320
        tree._validate()
321
321
 
324
324
        tree = self.get_committed_tree(['a'])
325
325
        tree.remove('a', keep_files=False)
326
326
        tree.remove('a', keep_files=False)
327
 
        self.failIfExists('a')
 
327
        self.assertPathDoesNotExist('a')
328
328
        tree._validate()
329
329
 
330
330
    def test_remove_file_and_containing_dir(self):
331
331
        tree = self.get_committed_tree(['config/', 'config/file'])
332
332
        tree.remove('config/file', keep_files=False)
333
333
        tree.remove('config', keep_files=False)
334
 
        self.failIfExists('config/file')
335
 
        self.failIfExists('config')
 
334
        self.assertPathDoesNotExist('config/file')
 
335
        self.assertPathDoesNotExist('config')
336
336
        tree._validate()
337
337
 
338
338
    def test_remove_dir_before_bzr(self):
340
340
        # or the bug doesn't manifest itself.
341
341
        tree = self.get_committed_tree(['.aaa/', '.aaa/file'])
342
342
        tree.remove('.aaa/', keep_files=False)
343
 
        self.failIfExists('.aaa/file')
344
 
        self.failIfExists('.aaa')
 
343
        self.assertPathDoesNotExist('.aaa/file')
 
344
        self.assertPathDoesNotExist('.aaa')
345
345
        tree._validate()