~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-29 22:03:03 UTC
  • mfrom: (5416.2.6 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
(mbp) Add 'break-lock --force'

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