3719.1.1
by Vincent Ladeuil
Fix bug #272648 |
1 |
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
16 |
|
17 |
"""Tests for interface conformance of 'WorkingTree.remove'"""
|
|
18 |
||
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
19 |
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree |
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
20 |
from bzrlib import errors, ignores, osutils |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
21 |
|
22 |
class TestRemove(TestCaseWithWorkingTree): |
|
23 |
"""Tests WorkingTree.remove"""
|
|
24 |
||
2475.5.2
by Marius Kruger
* blackbox/test_remove |
25 |
files = ['a', 'b/', 'b/c', 'd/'] |
26 |
rfiles = ['b/c', 'b', 'a', 'd'] |
|
2292.1.24
by Marius Kruger
minor text cleanups |
27 |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
28 |
def get_tree(self, files): |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
29 |
tree = self.make_branch_and_tree('.') |
2655.2.8
by Marius Kruger
* workingtree_implementations/test_remove |
30 |
self.build_tree(files) |
31 |
self.failUnlessExists(files) |
|
32 |
return tree |
|
33 |
||
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
34 |
def get_committed_tree(self, files, message="Committing"): |
35 |
tree = self.get_tree(files) |
|
2655.2.8
by Marius Kruger
* workingtree_implementations/test_remove |
36 |
tree.add(files) |
37 |
tree.commit(message) |
|
38 |
self.assertInWorkingTree(files) |
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
39 |
return tree |
40 |
||
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
41 |
def assertRemovedAndDeleted(self, files): |
42 |
self.assertNotInWorkingTree(files) |
|
43 |
self.failIfExists(files) |
|
44 |
||
45 |
def assertRemovedAndNotDeleted(self, files): |
|
46 |
self.assertNotInWorkingTree(files) |
|
47 |
self.failUnlessExists(files) |
|
48 |
||
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
49 |
def test_remove_keep(self): |
2655.2.4
by Marius Kruger
* workingtree.remove |
50 |
"""Check that files and directories are unversioned but not deleted."""
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
51 |
tree = self.get_tree(TestRemove.files) |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
52 |
tree.add(TestRemove.files) |
53 |
self.assertInWorkingTree(TestRemove.files) |
|
54 |
||
55 |
tree.remove(TestRemove.files) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
56 |
self.assertRemovedAndNotDeleted(TestRemove.files) |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
57 |
|
2655.2.4
by Marius Kruger
* workingtree.remove |
58 |
def test_remove_keep_subtree(self): |
59 |
"""Check that a directory is unversioned but not deleted."""
|
|
60 |
tree = self.make_branch_and_tree('.') |
|
61 |
subtree = self.make_branch_and_tree('subtree') |
|
62 |
tree.add('subtree', 'subtree-id') |
|
63 |
||
64 |
tree.remove('subtree') |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
65 |
self.assertRemovedAndNotDeleted('subtree') |
2655.2.4
by Marius Kruger
* workingtree.remove |
66 |
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
67 |
def test_remove_unchanged_files(self): |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
68 |
"""Check that unchanged files are removed and deleted."""
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
69 |
tree = self.get_committed_tree(TestRemove.files) |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
70 |
tree.remove(TestRemove.files, keep_files=False) |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
71 |
self.assertRemovedAndDeleted(TestRemove.files) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
72 |
tree._validate() |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
73 |
|
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
74 |
def test_remove_added_files(self): |
75 |
"""Removal of newly added files must fail."""
|
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
76 |
tree = self.get_tree(TestRemove.files) |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
77 |
tree.add(TestRemove.files) |
78 |
self.assertInWorkingTree(TestRemove.files) |
|
2475.5.6
by Marius Kruger
* test_remove |
79 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
80 |
TestRemove.files, keep_files=False) |
2475.5.6
by Marius Kruger
* test_remove |
81 |
self.assertContainsRe(err.changes_as_text, |
82 |
'(?s)added:.*a.*b/.*b/c.*d/') |
|
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
83 |
self.assertInWorkingTree(TestRemove.files) |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
84 |
self.failUnlessExists(TestRemove.files) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
85 |
tree._validate() |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
86 |
|
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
87 |
def test_remove_changed_file(self): |
88 |
"""Removal of a changed files must fail."""
|
|
3044.1.1
by Martin Pool
Fix up calls to TestCase.build_tree passing a string rather than a list |
89 |
tree = self.get_committed_tree(['a']) |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
90 |
self.build_tree_contents([('a', "some other new content!")]) |
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
91 |
self.assertInWorkingTree('a') |
2475.5.6
by Marius Kruger
* test_remove |
92 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
93 |
'a', keep_files=False) |
2475.5.6
by Marius Kruger
* test_remove |
94 |
self.assertContainsRe(err.changes_as_text, '(?s)modified:.*a') |
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
95 |
self.assertInWorkingTree('a') |
96 |
self.failUnlessExists('a') |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
97 |
tree._validate() |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
98 |
|
99 |
def test_remove_deleted_files(self): |
|
100 |
"""Check that files are removed if they don't exist any more."""
|
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
101 |
tree = self.get_committed_tree(TestRemove.files) |
2475.5.1
by Marius Kruger
Fix bug and test: bzr rm refuses to delete renamed files |
102 |
for f in TestRemove.rfiles: |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
103 |
osutils.delete_any(f) |
104 |
self.assertInWorkingTree(TestRemove.files) |
|
105 |
self.failIfExists(TestRemove.files) |
|
106 |
tree.remove(TestRemove.files, keep_files=False) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
107 |
self.assertRemovedAndDeleted(TestRemove.files) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
108 |
tree._validate() |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
109 |
|
2475.5.1
by Marius Kruger
Fix bug and test: bzr rm refuses to delete renamed files |
110 |
def test_remove_renamed_files(self): |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
111 |
"""Check that files are removed even if they are renamed."""
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
112 |
tree = self.get_committed_tree(TestRemove.files) |
2475.5.1
by Marius Kruger
Fix bug and test: bzr rm refuses to delete renamed files |
113 |
|
114 |
for f in TestRemove.rfiles: |
|
115 |
tree.rename_one(f,f+'x') |
|
116 |
rfilesx = ['bx/cx', 'bx', 'ax', 'dx'] |
|
117 |
self.assertInWorkingTree(rfilesx) |
|
118 |
self.failUnlessExists(rfilesx) |
|
119 |
||
120 |
tree.remove(rfilesx, keep_files=False) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
121 |
self.assertRemovedAndDeleted(rfilesx) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
122 |
tree._validate() |
2475.5.1
by Marius Kruger
Fix bug and test: bzr rm refuses to delete renamed files |
123 |
|
2475.5.2
by Marius Kruger
* blackbox/test_remove |
124 |
def test_remove_renamed_changed_files(self): |
125 |
"""Check that files are not removed if they are renamed and changed."""
|
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
126 |
tree = self.get_committed_tree(TestRemove.files) |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
127 |
|
128 |
for f in TestRemove.rfiles: |
|
129 |
tree.rename_one(f,f+'x') |
|
130 |
rfilesx = ['bx/cx', 'bx', 'ax', 'dx'] |
|
131 |
self.build_tree_contents([('ax','changed and renamed!'), |
|
132 |
('bx/cx','changed and renamed!')]) |
|
133 |
self.assertInWorkingTree(rfilesx) |
|
134 |
self.failUnlessExists(rfilesx) |
|
135 |
||
2475.5.6
by Marius Kruger
* test_remove |
136 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
137 |
rfilesx, keep_files=False) |
2475.5.6
by Marius Kruger
* test_remove |
138 |
self.assertContainsRe(err.changes_as_text, |
139 |
'(?s)modified:.*ax.*bx/cx') |
|
2475.5.2
by Marius Kruger
* blackbox/test_remove |
140 |
self.assertInWorkingTree(rfilesx) |
141 |
self.failUnlessExists(rfilesx) |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
142 |
tree._validate() |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
143 |
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
144 |
def test_force_remove_changed_files(self): |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
145 |
"""Check that changed files are removed and deleted when forced."""
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
146 |
tree = self.get_tree(TestRemove.files) |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
147 |
tree.add(TestRemove.files) |
148 |
self.assertInWorkingTree(TestRemove.files) |
|
149 |
||
150 |
tree.remove(TestRemove.files, keep_files=False, force=True) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
151 |
self.assertRemovedAndDeleted(TestRemove.files) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
152 |
tree._validate() |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
153 |
|
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
154 |
def test_remove_unknown_files(self): |
155 |
"""Try to delete unknown files."""
|
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
156 |
tree = self.get_tree(TestRemove.files) |
2475.5.6
by Marius Kruger
* test_remove |
157 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
158 |
TestRemove.files, keep_files=False) |
2475.5.6
by Marius Kruger
* test_remove |
159 |
self.assertContainsRe(err.changes_as_text, |
160 |
'(?s)unknown:.*d/.*b/c.*b/.*a.*') |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
161 |
tree._validate() |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
162 |
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
163 |
def test_remove_nonexisting_files(self): |
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
164 |
"""Try to delete non-existing files."""
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
165 |
tree = self.get_tree(TestRemove.files) |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
166 |
tree.remove([''], keep_files=False) |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
167 |
tree.remove(['xyz', 'abc/def'], keep_files=False) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
168 |
tree._validate() |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
169 |
|
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
170 |
def test_remove_unchanged_directory(self): |
2655.2.8
by Marius Kruger
* workingtree_implementations/test_remove |
171 |
"""Unchanged directories should be deleted."""
|
2655.2.6
by Marius Kruger
* workingtree.remove |
172 |
files = ['b/', 'b/c', 'b/sub_directory/', 'b/sub_directory/with_file'] |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
173 |
tree = self.get_committed_tree(files) |
2655.2.6
by Marius Kruger
* workingtree.remove |
174 |
tree.remove('b', keep_files=False) |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
175 |
self.assertRemovedAndDeleted('b') |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
176 |
tree._validate() |
177 |
||
178 |
def test_remove_absent_directory(self): |
|
179 |
"""Removing a absent directory succeeds without corruption (#150438)."""
|
|
180 |
paths = ['a/', 'a/b'] |
|
181 |
tree = self.get_committed_tree(paths) |
|
182 |
self.get_transport('.').delete_tree('a') |
|
183 |
tree.remove(['a']) |
|
184 |
self.assertRemovedAndDeleted('b') |
|
185 |
tree._validate() |
|
2292.1.30
by Marius Kruger
* Minor text fixes. |
186 |
|
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
187 |
def test_remove_unknown_ignored_files(self): |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
188 |
"""Unknown ignored files should be deleted."""
|
189 |
tree = self.get_committed_tree(['b/']) |
|
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
190 |
ignores.add_runtime_ignores(["*ignored*"]) |
191 |
||
192 |
self.build_tree(['unknown_ignored_file']) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
193 |
self.assertNotEquals(None, tree.is_ignored('unknown_ignored_file')) |
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
194 |
tree.remove('unknown_ignored_file', keep_files=False) |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
195 |
self.assertRemovedAndDeleted('unknown_ignored_file') |
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
196 |
|
197 |
self.build_tree(['b/unknown_ignored_file', 'b/unknown_ignored_dir/']) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
198 |
self.assertNotEquals(None, tree.is_ignored('b/unknown_ignored_file')) |
199 |
self.assertNotEquals(None, tree.is_ignored('b/unknown_ignored_dir')) |
|
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
200 |
tree.remove('b', keep_files=False) |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
201 |
self.assertRemovedAndDeleted('b') |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
202 |
tree._validate() |
2655.2.12
by Marius Kruger
Remove unknown ignored files wihtout needing --force' |
203 |
|
3042.2.1
by Lukáš Lalinský
Fix ``bzr rm`` to not delete modified and ignored files. |
204 |
def test_remove_changed_ignored_files(self): |
205 |
"""Changed ignored files should not be deleted."""
|
|
206 |
files = ['an_ignored_file'] |
|
207 |
tree = self.get_tree(files) |
|
208 |
tree.add(files) |
|
209 |
ignores.add_runtime_ignores(["*ignored*"]) |
|
210 |
self.assertInWorkingTree(files) |
|
211 |
self.assertNotEquals(None, tree.is_ignored(files[0])) |
|
212 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
|
213 |
files, keep_files=False) |
|
214 |
self.assertContainsRe(err.changes_as_text, |
|
215 |
'(?s)added:.*' + files[0]) |
|
216 |
self.assertInWorkingTree(files) |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
217 |
tree._validate() |
3042.2.1
by Lukáš Lalinský
Fix ``bzr rm`` to not delete modified and ignored files. |
218 |
|
2655.2.8
by Marius Kruger
* workingtree_implementations/test_remove |
219 |
def test_dont_remove_directory_with_unknowns(self): |
220 |
"""Directories with unknowns should not be deleted."""
|
|
221 |
directories = ['a/', 'b/', 'c/', 'c/c/'] |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
222 |
tree = self.get_committed_tree(directories) |
2655.2.8
by Marius Kruger
* workingtree_implementations/test_remove |
223 |
|
224 |
self.build_tree(['a/unknown_file']) |
|
225 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
|
226 |
'a', keep_files=False) |
|
227 |
self.assertContainsRe(err.changes_as_text, |
|
228 |
'(?s)unknown:.*a/unknown_file') |
|
229 |
||
230 |
self.build_tree(['b/unknown_directory']) |
|
231 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
|
232 |
'b', keep_files=False) |
|
233 |
self.assertContainsRe(err.changes_as_text, |
|
234 |
'(?s)unknown:.*b/unknown_directory') |
|
235 |
||
236 |
self.build_tree(['c/c/unknown_file']) |
|
237 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
|
238 |
'c/c', keep_files=False) |
|
239 |
self.assertContainsRe(err.changes_as_text, |
|
240 |
'(?s)unknown:.*c/c/unknown_file') |
|
241 |
||
242 |
self.assertInWorkingTree(directories) |
|
243 |
self.failUnlessExists(directories) |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
244 |
tree._validate() |
2655.2.8
by Marius Kruger
* workingtree_implementations/test_remove |
245 |
|
246 |
def test_force_remove_directory_with_unknowns(self): |
|
2655.2.4
by Marius Kruger
* workingtree.remove |
247 |
"""Unchanged non-empty directories should be deleted when forced."""
|
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
248 |
files = ['b/', 'b/c'] |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
249 |
tree = self.get_committed_tree(files) |
2655.2.4
by Marius Kruger
* workingtree.remove |
250 |
|
251 |
other_files = ['b/unknown_file', 'b/sub_directory/', |
|
2655.2.6
by Marius Kruger
* workingtree.remove |
252 |
'b/sub_directory/with_file', 'b/sub_directory/sub_directory/'] |
2655.2.4
by Marius Kruger
* workingtree.remove |
253 |
self.build_tree(other_files) |
254 |
||
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
255 |
self.assertInWorkingTree(files) |
256 |
self.failUnlessExists(files) |
|
257 |
||
258 |
tree.remove('b', keep_files=False, force=True) |
|
259 |
||
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
260 |
self.assertRemovedAndDeleted(files) |
261 |
self.assertRemovedAndDeleted(other_files) |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
262 |
tree._validate() |
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
263 |
|
2292.1.25
by Marius Kruger
* Add utility method delta.get_changes_as_text to get the output of .show() |
264 |
def test_remove_directory_with_changed_file(self): |
265 |
"""Refuse to delete directories with changed files."""
|
|
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
266 |
files = ['b/', 'b/c'] |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
267 |
tree = self.get_committed_tree(files) |
2475.5.2
by Marius Kruger
* blackbox/test_remove |
268 |
self.build_tree_contents([('b/c', "some other new content!")]) |
2655.2.6
by Marius Kruger
* workingtree.remove |
269 |
|
2475.5.6
by Marius Kruger
* test_remove |
270 |
err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove, |
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
271 |
'b', keep_files=False) |
2475.5.6
by Marius Kruger
* test_remove |
272 |
self.assertContainsRe(err.changes_as_text, '(?s)modified:.*b/c') |
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
273 |
self.assertInWorkingTree(files) |
274 |
self.failUnlessExists(files) |
|
2292.1.20
by Marius Kruger
move test_workingtree.TestRemove to workingtree_implementations/test_remove |
275 |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
276 |
# see if we can force it now..
|
2655.2.9
by Marius Kruger
* workingtree_implementations/test_remove |
277 |
tree.remove('b', keep_files=False, force=True) |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
278 |
self.assertRemovedAndDeleted(files) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
279 |
tree._validate() |
1551.15.11
by Aaron Bentley
Bugfix WorkingTree.remove to handle subtrees, and non-cwd trees |
280 |
|
2655.2.11
by Marius Kruger
* Update NEWS |
281 |
def test_remove_directory_with_renames(self): |
282 |
"""Delete directory with renames in or out."""
|
|
2655.2.10
by Marius Kruger
add test for removing a direcory with something that has been moved out |
283 |
|
2655.2.11
by Marius Kruger
* Update NEWS |
284 |
files = ['a/', 'a/file', 'a/directory/', 'b/'] |
2655.2.10
by Marius Kruger
add test for removing a direcory with something that has been moved out |
285 |
files_to_move = ['a/file', 'a/directory/'] |
286 |
||
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
287 |
tree = self.get_committed_tree(files) |
288 |
# move stuff from a=>b
|
|
2655.2.10
by Marius Kruger
add test for removing a direcory with something that has been moved out |
289 |
tree.move(['a/file', 'a/directory'], to_dir='b') |
290 |
||
291 |
moved_files = ['b/file', 'b/directory/'] |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
292 |
self.assertRemovedAndDeleted(files_to_move) |
2655.2.10
by Marius Kruger
add test for removing a direcory with something that has been moved out |
293 |
self.assertInWorkingTree(moved_files) |
294 |
self.failUnlessExists(moved_files) |
|
295 |
||
2655.2.11
by Marius Kruger
* Update NEWS |
296 |
# check if it works with renames out
|
2655.2.10
by Marius Kruger
add test for removing a direcory with something that has been moved out |
297 |
tree.remove('a', keep_files=False) |
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
298 |
self.assertRemovedAndDeleted(['a/']) |
2655.2.11
by Marius Kruger
* Update NEWS |
299 |
|
300 |
# check if it works with renames in
|
|
301 |
tree.remove('b', keep_files=False) |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
302 |
self.assertRemovedAndDeleted(['b/']) |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
303 |
tree._validate() |
2655.2.10
by Marius Kruger
add test for removing a direcory with something that has been moved out |
304 |
|
1551.15.11
by Aaron Bentley
Bugfix WorkingTree.remove to handle subtrees, and non-cwd trees |
305 |
def test_non_cwd(self): |
306 |
tree = self.make_branch_and_tree('tree') |
|
307 |
self.build_tree(['tree/dir/', 'tree/dir/file']) |
|
308 |
tree.add(['dir', 'dir/file']) |
|
309 |
tree.commit('add file') |
|
310 |
tree.remove('dir/', keep_files=False) |
|
311 |
self.failIfExists('tree/dir/file') |
|
2655.2.15
by Marius Kruger
Apply Alexander's comments: |
312 |
self.assertNotInWorkingTree('tree/dir/file', 'tree') |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
313 |
tree._validate() |
2967.5.8
by Daniel Watkins
Moved tests to correct location. |
314 |
|
315 |
def test_remove_uncommitted_removed_file(self): |
|
316 |
# As per bug #152811
|
|
317 |
tree = self.get_committed_tree(['a']) |
|
318 |
tree.remove('a', keep_files=False) |
|
319 |
tree.remove('a', keep_files=False) |
|
2967.5.12
by Daniel Watkins
Modified tests as suggested on-list. |
320 |
self.failIfExists('a') |
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
321 |
tree._validate() |
2967.5.8
by Daniel Watkins
Moved tests to correct location. |
322 |
|
323 |
def test_remove_file_and_containing_dir(self): |
|
324 |
tree = self.get_committed_tree(['config/', 'config/file']) |
|
325 |
tree.remove('config/file', keep_files=False) |
|
326 |
tree.remove('config', keep_files=False) |
|
2967.5.12
by Daniel Watkins
Modified tests as suggested on-list. |
327 |
self.failIfExists('config/file') |
328 |
self.failIfExists('config') |
|
3585.2.1
by Robert Collins
Create acceptance test for bug 150438. |
329 |
tree._validate() |
3719.1.1
by Vincent Ladeuil
Fix bug #272648 |
330 |
|
331 |
def test_remove_dir_before_bzr(self): |
|
332 |
# As per bug #272648. Note that a file must be present in the directory
|
|
333 |
# or the bug doesn't manifest itself.
|
|
334 |
tree = self.get_committed_tree(['.aaa/', '.aaa/file']) |
|
335 |
tree.remove('.aaa/', keep_files=False) |
|
336 |
self.failIfExists('.aaa/file') |
|
337 |
self.failIfExists('.aaa') |
|
338 |
tree._validate() |