~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: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import os
19
19
import sys
20
20
 
21
 
from bzrlib.tests import SymlinkFeature, TestSkipped
22
 
from bzrlib.tests import TestCaseWithTransport
 
21
from bzrlib.tests import (
 
22
    script,
 
23
    features,
 
24
    TestCaseWithTransport,
 
25
    TestSkipped,
 
26
    )
23
27
from bzrlib.workingtree import WorkingTree
24
28
from bzrlib import osutils
25
29
 
49
53
        for f in files:
50
54
            id=f+_id
51
55
            self.assertNotInWorkingTree(f)
52
 
            self.failIfExists(f)
 
56
            self.assertPathDoesNotExist(f)
53
57
 
54
58
    def assertFilesUnversioned(self, files):
55
59
        for f in files:
56
60
            self.assertNotInWorkingTree(f)
57
 
            self.failUnlessExists(f)
 
61
            self.assertPathExists(f)
58
62
 
59
63
    def changeFile(self, file_name):
60
64
        f = file(file_name, 'ab')
76
80
        self.assertEqual('', err)
77
81
        self.assertEqual('', out)
78
82
        self.assertInWorkingTree('foo', tree=tree)
79
 
        self.failUnlessExists('foo')
 
83
        self.assertPathExists('foo')
80
84
 
81
85
    def test_remove_no_files_specified_missing_dir_and_contents(self):
82
86
        tree = self._make_tree_and_add(
90
94
            err)
91
95
        # non-missing paths not touched:
92
96
        self.assertInWorkingTree('foo', tree=tree)
93
 
        self.failUnlessExists('foo')
 
97
        self.assertPathExists('foo')
94
98
        self.assertInWorkingTree('dir', tree=tree)
95
 
        self.failUnlessExists('dir')
 
99
        self.assertPathExists('dir')
96
100
        # missing files unversioned
97
101
        self.assertNotInWorkingTree('dir/missing', tree=tree)
98
102
        self.assertNotInWorkingTree('dir/missing/child', tree=tree)
116
120
        self.assertEqual('removed bar\n', err)
117
121
        # non-missing files not touched:
118
122
        self.assertInWorkingTree('foo', tree=tree)
119
 
        self.failUnlessExists('foo')
 
123
        self.assertPathExists('foo')
120
124
        # missing files unversioned
121
125
        self.assertNotInWorkingTree('bar', tree=tree)
122
126
 
123
127
    def test_remove_no_files_specified_missing_link(self):
124
 
        self.requireFeature(SymlinkFeature)
 
128
        self.requireFeature(features.SymlinkFeature)
125
129
        tree = self._make_tree_and_add(['foo'])
126
130
        os.symlink('foo', 'linkname')
127
131
        tree.add(['linkname'])
131
135
        self.assertEqual('removed linkname\n', err)
132
136
        # non-missing files not touched:
133
137
        self.assertInWorkingTree('foo', tree=tree)
134
 
        self.failUnlessExists('foo')
 
138
        self.assertPathExists('foo')
135
139
        # missing files unversioned
136
140
        self.assertNotInWorkingTree('linkname', tree=tree)
137
141
 
192
196
        self.run_bzr_remove_changed_files(
193
197
            ['../a', 'c', '.', '../d'], working_dir='b')
194
198
        self.assertNotInWorkingTree(files)
195
 
        self.failIfExists(files)
 
199
        self.assertPathDoesNotExist(files)
196
200
 
197
201
    def test_remove_keep_unversioned_files(self):
198
202
        self.build_tree(files)
200
204
        self.run_bzr('remove --keep a', error_regexes=["a is not versioned."])
201
205
        self.assertFilesUnversioned(files)
202
206
 
 
207
    def test_remove_no_backup_unversioned_files(self):
 
208
        self.build_tree(files)
 
209
        tree = self.make_branch_and_tree('.')
 
210
        script.ScriptRunner().run_script(self, '''
 
211
        $ bzr remove --no-backup a b/ b/c d/
 
212
        2>deleted d
 
213
        2>removed b/c (but kept a copy: b/c.~1~)
 
214
        2>deleted b
 
215
        2>deleted a
 
216
        ''')
 
217
        self.assertFilesDeleted(files)
 
218
 
203
219
    def test_remove_force_unversioned_files(self):
204
220
        self.build_tree(files)
205
221
        tree = self.make_branch_and_tree('.')
206
 
        self.run_bzr(['remove', '--force'] + list(files),
207
 
                     error_regexes=["deleted a", "deleted b",
208
 
                                    "removed b/c", "deleted d"])
 
222
        script.ScriptRunner().run_script(self, '''
 
223
        $ bzr remove --force a b/ b/c d/
 
224
        2>(The --force option is deprecated, rather use --no-backup in future.)
 
225
        2>deleted d
 
226
        2>removed b/c (but kept a copy: b/c.~1~)
 
227
        2>deleted b
 
228
        2>deleted a
 
229
        ''')
209
230
        self.assertFilesDeleted(files)
210
231
 
211
232
    def test_remove_deleted_files(self):
216
237
        for f in my_files:
217
238
            osutils.delete_any(f)
218
239
        self.assertInWorkingTree(files)
219
 
        self.failIfExists(files)
 
240
        self.assertPathDoesNotExist(files)
220
241
        self.run_bzr('remove ' + ' '.join(files))
221
242
        self.assertNotInWorkingTree(a)
222
 
        self.failIfExists(files)
 
243
        self.assertPathDoesNotExist(files)
223
244
 
224
245
    def test_remove_non_existing_files(self):
225
246
        tree = self._make_tree_and_add([])