70
71
#see if we can force it now
71
72
self.run_bzr(['remove', '--force'] + list(files_to_remove))
74
def test_remove_new_no_files_specified(self):
75
tree = self.make_branch_and_tree('.')
76
self.run_bzr_error(["bzr: ERROR: No matching files."], 'remove --new')
77
self.run_bzr_error(["bzr: ERROR: No matching files."], 'remove --new .')
73
79
def test_remove_no_files_specified(self):
74
tree = self._make_add_and_assert_tree([])
75
self.run_bzr_error(["bzr: ERROR: Specify one or more files to remove, "
76
"or use --new."], 'remove')
78
self.run_bzr_error(["bzr: ERROR: No matching files."], 'remove --new')
80
self.run_bzr_error(["bzr: ERROR: No matching files."],
80
tree = self._make_tree_and_add(['foo'])
81
out, err = self.run_bzr(['rm'])
82
self.assertEqual('', err)
83
self.assertEqual('', out)
84
self.assertInWorkingTree('foo', tree=tree)
85
self.failUnlessExists('foo')
87
def test_remove_no_files_specified_missing_dir_and_contents(self):
88
tree = self._make_tree_and_add(
89
['foo', 'dir/', 'dir/missing/', 'dir/missing/child'])
90
self.get_transport('.').delete_tree('dir/missing')
91
out, err = self.run_bzr(['rm'])
92
self.assertEqual('', out)
94
'removed dir/missing/child\n'
95
'removed dir/missing\n',
97
# non-missing paths not touched:
98
self.assertInWorkingTree('foo', tree=tree)
99
self.failUnlessExists('foo')
100
self.assertInWorkingTree('dir', tree=tree)
101
self.failUnlessExists('dir')
102
# missing files unversioned
103
self.assertNotInWorkingTree('dir/missing', tree=tree)
104
self.assertNotInWorkingTree('dir/missing/child', tree=tree)
106
def test_remove_no_files_specified_already_deleted(self):
107
tree = self._make_tree_and_add(['foo', 'bar'])
108
tree.commit('save foo and bar')
111
self.assertEqual(None, tree.path2id('bar'))
112
# Running rm with a deleted file does not error.
113
out, err = self.run_bzr(['rm'])
114
self.assertEqual('', out)
115
self.assertEqual('', err)
117
def test_remove_no_files_specified_missing_file(self):
118
tree = self._make_tree_and_add(['foo', 'bar'])
120
out, err = self.run_bzr(['rm'])
121
self.assertEqual('', out)
122
self.assertEqual('removed bar\n', err)
123
# non-missing files not touched:
124
self.assertInWorkingTree('foo', tree=tree)
125
self.failUnlessExists('foo')
126
# missing files unversioned
127
self.assertNotInWorkingTree('bar', tree=tree)
129
def test_remove_no_files_specified_missing_link(self):
130
self.requireFeature(SymlinkFeature)
131
tree = self._make_tree_and_add(['foo'])
132
os.symlink('foo', 'linkname')
133
tree.add(['linkname'])
134
os.unlink('linkname')
135
out, err = self.run_bzr(['rm'])
136
self.assertEqual('', out)
137
self.assertEqual('removed linkname\n', err)
138
# non-missing files not touched:
139
self.assertInWorkingTree('foo', tree=tree)
140
self.failUnlessExists('foo')
141
# missing files unversioned
142
self.assertNotInWorkingTree('linkname', tree=tree)
83
144
def test_rm_one_file(self):
84
tree = self._make_add_and_assert_tree([a])
145
tree = self._make_tree_and_add([a])
85
146
self.run_bzr("commit -m 'added a'")
86
147
self.run_bzr('rm a', error_regexes=["deleted a"])
87
148
self.assertFilesDeleted([a])
89
150
def test_remove_one_file(self):
90
tree = self._make_add_and_assert_tree([a])
151
tree = self._make_tree_and_add([a])
91
152
self.run_bzr("commit -m 'added a'")
92
153
self.run_bzr('remove a', error_regexes=["deleted a"])
93
154
self.assertFilesDeleted([a])
95
156
def test_remove_keep_one_file(self):
96
tree = self._make_add_and_assert_tree([a])
157
tree = self._make_tree_and_add([a])
97
158
self.run_bzr('remove --keep a', error_regexes=["removed a"])
98
159
self.assertFilesUnversioned([a])
100
161
def test_remove_one_deleted_file(self):
101
tree = self._make_add_and_assert_tree([a])
162
tree = self._make_tree_and_add([a])
102
163
self.run_bzr("commit -m 'added a'")
104
165
self.assertInWorkingTree(a)
117
178
['unknown:[.\s]*d/[.\s]*b/c[.\s]*b/[.\s]*a'], files)
119
180
def test_remove_changed_files(self):
120
tree = self._make_add_and_assert_tree(files)
181
tree = self._make_tree_and_add(files)
121
182
self.run_bzr("commit -m 'added files'")
122
183
self.changeFile(a)
123
184
self.changeFile(c)
124
185
self.run_bzr_remove_changed_files(['modified:[.\s]*a[.\s]*b/c'], files)
126
187
def test_remove_changed_ignored_files(self):
127
tree = self._make_add_and_assert_tree(['a'])
188
tree = self._make_tree_and_add(['a'])
128
189
self.run_bzr(['ignore', 'a'])
129
190
self.run_bzr_remove_changed_files(['added:[.\s]*a'], ['a'])
131
192
def test_remove_changed_files_from_child_dir(self):
132
193
if sys.platform == 'win32':
133
194
raise TestSkipped("Windows unable to remove '.' directory")
134
tree = self._make_add_and_assert_tree(files)
195
tree = self._make_tree_and_add(files)
135
196
self.run_bzr("commit -m 'added files'")
136
197
self.changeFile(a)
137
198
self.changeFile(c)