63
63
self.assertEqual(TreeLink().kind_character(), '')
66
files=['a','b/','b/c']
67
67
class TestRemove(TestCaseWithTransport):
68
68
"""Tests WorkingTree.remove"""
70
files=['a','b/','b/c']
71
75
self.makeAndChdirToTestDir()
72
76
tree = self.make_branch_and_tree('.')
73
self.build_tree(files)
77
self.build_tree(TestRemove.files)
76
80
def test_remove_unchanged_files(self):
77
81
"""check that unchanged files are removed and deleted."""
78
82
tree = self.getTree()
83
tree.add(TestRemove.files)
80
84
tree.commit("files must not have changes")
82
self.assertInWorkingTree(files)
84
tree.remove(files, keep_files=False)
86
self.assertNotInWorkingTree(files)
87
self.failIfExists(files)
86
self.assertInWorkingTree(TestRemove.files)
88
tree.remove(TestRemove.files, keep_files=False)
90
self.assertNotInWorkingTree(TestRemove.files)
91
self.failIfExists(TestRemove.files)
89
93
def test_remove_changed_files(self):
90
94
"""check that changed files are removed but not deleted."""
91
95
tree = self.getTree()
93
self.assertInWorkingTree(files)
95
tree.remove(files, keep_files=False)
97
self.assertNotInWorkingTree(files)
98
self.failUnlessExists(files)
96
tree.add(TestRemove.files)
97
self.assertInWorkingTree(TestRemove.files)
99
tree.remove(TestRemove.files, keep_files=False)
101
self.assertNotInWorkingTree(TestRemove.files)
102
self.failUnlessExists(TestRemove.files)
100
104
def test_force_remove_changed_files(self):
101
105
"""check that changed files are removed and deleted when forced."""
102
106
tree = self.getTree()
104
self.assertInWorkingTree(files)
106
tree.remove(files, keep_files=False, force=True)
108
self.assertNotInWorkingTree(files)
109
self.failIfExists(files)
107
tree.add(TestRemove.files)
108
self.assertInWorkingTree(TestRemove.files)
110
tree.remove(TestRemove.files, keep_files=False, force=True)
112
self.assertNotInWorkingTree(TestRemove.files)
113
self.failIfExists(TestRemove.files)
111
115
def test_remove_nonexisting_files(self):
112
116
"""delete files which does not exist."""
113
117
tree = self.getTree()
114
tree.remove(files, keep_files=False)
118
tree.remove(TestRemove.files, keep_files=False)
115
119
tree.remove([''], keep_files=False)
116
tree.remove(['b'], keep_files=False)
120
tree.remove(TestRemove.b, keep_files=False)
118
122
def test_remove_nonempty_directory(self):
119
123
tree = self.getTree()
124
tree.add(TestRemove.files)
121
125
tree.commit("make sure b is versioned")
122
self.assertInWorkingTree(files)
123
self.failUnlessExists(files)
125
tree.remove(b, keep_files=False)
126
self.assertNotInWorkingTree(b)
127
self.failUnlessExists(b)
126
self.assertInWorkingTree(TestRemove.files)
127
self.failUnlessExists(TestRemove.files)
128
tree.remove(TestRemove.b, keep_files=False)
129
self.assertNotInWorkingTree(TestRemove.b)
130
self.failUnlessExists(TestRemove.b)
129
132
def test_force_remove_nonempty_directory(self):
130
133
tree = self.getTree()
134
tree.add(TestRemove.files)
132
135
tree.commit("make sure b is versioned")
133
self.assertInWorkingTree(files)
134
self.failUnlessExists(files)
135
tree.remove(['b'], keep_files=False, force=True)
137
self.assertNotInWorkingTree(b_c)
138
self.failIfExists(b_c)
136
self.assertInWorkingTree(TestRemove.files)
137
self.failUnlessExists(TestRemove.files)
138
tree.remove(TestRemove.b, keep_files=False, force=True)
139
self.assertNotInWorkingTree(TestRemove.b_c)
140
self.failIfExists(TestRemove.b_c)
140
142
def test_remove_keep(self):
141
143
"""check that files are unversioned but not delete."""
142
144
tree = self.getTree()
144
self.assertInWorkingTree(files)
145
tree.add(TestRemove.files)
146
self.assertInWorkingTree(TestRemove.files)
147
self.assertNotInWorkingTree(files)
148
self.failUnlessExists(files)
148
tree.remove(TestRemove.files)
149
self.assertNotInWorkingTree(TestRemove.files)
150
self.failUnlessExists(TestRemove.files)
150
152
class TestDefaultFormat(TestCaseWithTransport):