~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
import sys
20
20
 
21
21
from bzrlib.tests import SymlinkFeature, TestSkipped
22
 
from bzrlib.tests.blackbox import ExternalBase
 
22
from bzrlib.tests import TestCaseWithTransport
23
23
from bzrlib.workingtree import WorkingTree
24
24
from bzrlib import osutils
25
25
 
31
31
files=(a, b, c, d)
32
32
 
33
33
 
34
 
class TestRemove(ExternalBase):
 
34
class TestRemove(TestCaseWithTransport):
35
35
 
36
36
    def _make_tree_and_add(self, paths):
37
37
        tree = self.make_branch_and_tree('.')
61
61
        f.write("\nsome other new content!")
62
62
        f.close()
63
63
 
64
 
    def run_bzr_remove_changed_files(self, error_regexes, files_to_remove):
65
 
        error_regexes.extend(["Can't safely remove modified or unknown files:",
66
 
            'Use --keep to not delete them,'
67
 
            ' or --force to delete them regardless.'
68
 
            ])
69
 
        self.run_bzr_error(error_regexes,
70
 
            ['remove'] + list(files_to_remove))
71
 
        #see if we can force it now
72
 
        self.run_bzr(['remove', '--force'] + list(files_to_remove))
 
64
    def run_bzr_remove_changed_files(self, files_to_remove, working_dir=None):
 
65
        self.run_bzr(['remove'] + list(files_to_remove),
 
66
           working_dir=working_dir)
73
67
 
74
68
    def test_remove_new_no_files_specified(self):
75
69
        tree = self.make_branch_and_tree('.')
174
168
    def test_remove_unversioned_files(self):
175
169
        self.build_tree(files)
176
170
        tree = self.make_branch_and_tree('.')
177
 
        self.run_bzr_remove_changed_files(
178
 
            ['unknown:[.\s]*d/[.\s]*b/c[.\s]*b/[.\s]*a'], files)
 
171
        self.run_bzr_remove_changed_files(files)
179
172
 
180
173
    def test_remove_changed_files(self):
181
174
        tree = self._make_tree_and_add(files)
182
175
        self.run_bzr("commit -m 'added files'")
183
176
        self.changeFile(a)
184
177
        self.changeFile(c)
185
 
        self.run_bzr_remove_changed_files(['modified:[.\s]*a[.\s]*b/c'], files)
 
178
        self.run_bzr_remove_changed_files(files)
186
179
 
187
180
    def test_remove_changed_ignored_files(self):
188
181
        tree = self._make_tree_and_add(['a'])
189
182
        self.run_bzr(['ignore', 'a'])
190
 
        self.run_bzr_remove_changed_files(['added:[.\s]*a'], ['a'])
 
183
        self.run_bzr_remove_changed_files(['a'])
191
184
 
192
185
    def test_remove_changed_files_from_child_dir(self):
193
186
        if sys.platform == 'win32':
196
189
        self.run_bzr("commit -m 'added files'")
197
190
        self.changeFile(a)
198
191
        self.changeFile(c)
199
 
        os.chdir('b')
200
 
        self.run_bzr_remove_changed_files(['modified:[.\s]*a[.\s]*b/c'],
201
 
            ['../a', 'c', '.', '../d'])
202
 
        os.chdir('..')
 
192
        self.run_bzr_remove_changed_files(
 
193
            ['../a', 'c', '.', '../d'], working_dir='b')
203
194
        self.assertNotInWorkingTree(files)
204
195
        self.failIfExists(files)
205
196
 
214
205
        tree = self.make_branch_and_tree('.')
215
206
        self.run_bzr(['remove', '--force'] + list(files),
216
207
                     error_regexes=["deleted a", "deleted b",
217
 
                                    "deleted b/c", "deleted d"])
 
208
                                    "removed b/c", "deleted d"])
218
209
        self.assertFilesDeleted(files)
219
210
 
220
211
    def test_remove_deleted_files(self):