~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-02-09 17:27:46 UTC
  • mto: (5029.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5030.
  • Revision ID: v.ladeuil+lp@free.fr-20100209172746-6f4mvlnr2mac807j
Move NoSmartTransportServer to bzrlib.tests.test_server

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 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 import TestCaseWithTransport
 
22
from bzrlib.tests.blackbox import ExternalBase
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(TestCaseWithTransport):
 
34
class TestRemove(ExternalBase):
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, files_to_remove, working_dir=None):
65
 
        self.run_bzr(['remove'] + list(files_to_remove),
66
 
           working_dir=working_dir)
 
64
    def run_bzr_remove_changed_files(self, error_regexes, files_to_remove,
 
65
                                     working_dir=None):
 
66
        error_regexes.extend(["Can't safely remove modified or unknown files:",
 
67
            'Use --keep to not delete them,'
 
68
            ' or --force to delete them regardless.'
 
69
            ])
 
70
        self.run_bzr_error(error_regexes,
 
71
                           ['remove'] + list(files_to_remove),
 
72
                           working_dir=working_dir)
 
73
        #see if we can force it now
 
74
        self.run_bzr(['remove', '--force'] + list(files_to_remove),
 
75
                     working_dir=working_dir)
67
76
 
68
77
    def test_remove_new_no_files_specified(self):
69
78
        tree = self.make_branch_and_tree('.')
168
177
    def test_remove_unversioned_files(self):
169
178
        self.build_tree(files)
170
179
        tree = self.make_branch_and_tree('.')
171
 
        self.run_bzr_remove_changed_files(files)
 
180
        self.run_bzr_remove_changed_files(
 
181
            ['unknown:[.\s]*d/[.\s]*b/c[.\s]*b/[.\s]*a'], files)
172
182
 
173
183
    def test_remove_changed_files(self):
174
184
        tree = self._make_tree_and_add(files)
175
185
        self.run_bzr("commit -m 'added files'")
176
186
        self.changeFile(a)
177
187
        self.changeFile(c)
178
 
        self.run_bzr_remove_changed_files(files)
 
188
        self.run_bzr_remove_changed_files(['modified:[.\s]*a[.\s]*b/c'], files)
179
189
 
180
190
    def test_remove_changed_ignored_files(self):
181
191
        tree = self._make_tree_and_add(['a'])
182
192
        self.run_bzr(['ignore', 'a'])
183
 
        self.run_bzr_remove_changed_files(['a'])
 
193
        self.run_bzr_remove_changed_files(['added:[.\s]*a'], ['a'])
184
194
 
185
195
    def test_remove_changed_files_from_child_dir(self):
186
196
        if sys.platform == 'win32':
190
200
        self.changeFile(a)
191
201
        self.changeFile(c)
192
202
        self.run_bzr_remove_changed_files(
 
203
            ['modified:[.\s]*a[.\s]*b/c'],
193
204
            ['../a', 'c', '.', '../d'], working_dir='b')
194
205
        self.assertNotInWorkingTree(files)
195
206
        self.failIfExists(files)
205
216
        tree = self.make_branch_and_tree('.')
206
217
        self.run_bzr(['remove', '--force'] + list(files),
207
218
                     error_regexes=["deleted a", "deleted b",
208
 
                                    "removed b/c", "deleted d"])
 
219
                                    "deleted b/c", "deleted d"])
209
220
        self.assertFilesDeleted(files)
210
221
 
211
222
    def test_remove_deleted_files(self):