~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2014-05-08 02:56:29 UTC
  • mfrom: (6596.1.1 bzr)
  • Revision ID: pqm@pqm.ubuntu.com-20140508025629-de62pqrditrp349y
(richard-wilbur) Jelmer: Don't pass blob to file.writelines(),
 but rather to file.write(). (Dimitri John Ledkov)

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
 
203
 
    def test_remove_force_unversioned_files(self):
 
207
    def test_remove_no_backup_unversioned_files(self):
204
208
        self.build_tree(files)
205
209
        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"])
 
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
        ''')
209
217
        self.assertFilesDeleted(files)
210
218
 
211
219
    def test_remove_deleted_files(self):
216
224
        for f in my_files:
217
225
            osutils.delete_any(f)
218
226
        self.assertInWorkingTree(files)
219
 
        self.failIfExists(files)
 
227
        self.assertPathDoesNotExist(files)
220
228
        self.run_bzr('remove ' + ' '.join(files))
221
229
        self.assertNotInWorkingTree(a)
222
 
        self.failIfExists(files)
 
230
        self.assertPathDoesNotExist(files)
223
231
 
224
232
    def test_remove_non_existing_files(self):
225
233
        tree = self._make_tree_and_add([])