113
113
self.assertEquals(delta.added[0][0], 'dir')
114
114
self.failIf(delta.modified)
116
def test_branch_add_in_unversioned(self):
116
def test_working_tree_add_in_unversioned(self):
117
117
"""Try to add a file in an unversioned directory.
119
"bzr add" adds the parent as necessary, but simple branch add
119
"bzr add" adds the parent as necessary, but simple working tree add
122
122
from bzrlib.branch import Branch
123
123
from bzrlib.errors import NotVersionedError
124
from bzrlib.workingtree import WorkingTree
125
126
b = Branch.initialize('.')
130
131
self.assertRaises(NotVersionedError,
132
WorkingTree(b.base, b).add,
134
135
self.check_branch()
136
def test_add_in_unversioned(self):
137
"""Try to add a file in an unversioned directory.
139
"bzr add" should add the parent(s) as necessary.
141
from bzrlib.branch import Branch
142
eq = self.assertEqual
144
b = Branch.initialize('.')
146
self.build_tree(['inertiatic/', 'inertiatic/esp'])
147
eq(list(b.unknowns()), ['inertiatic'])
148
self.run_bzr('add', 'inertiatic/esp')
149
eq(list(b.unknowns()), [])
151
# Multiple unversioned parents
152
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
153
eq(list(b.unknowns()), ['veil'])
154
self.run_bzr('add', 'veil/cerpin/taxt')
155
eq(list(b.unknowns()), [])
157
# Check whacky paths work
158
self.build_tree(['cicatriz/', 'cicatriz/esp'])
159
eq(list(b.unknowns()), ['cicatriz'])
160
self.run_bzr('add', 'inertiatic/../cicatriz/esp')
161
eq(list(b.unknowns()), [])
163
def test_add_in_versioned(self):
164
"""Try to add a file in a versioned directory.
166
"bzr add" should do this happily.
168
from bzrlib.branch import Branch
169
eq = self.assertEqual
171
b = Branch.initialize('.')
173
self.build_tree(['inertiatic/', 'inertiatic/esp'])
174
eq(list(b.unknowns()), ['inertiatic'])
175
self.run_bzr('add', '--no-recurse', 'inertiatic')
176
eq(list(b.unknowns()), ['inertiatic'+os.sep+'esp'])
177
self.run_bzr('add', 'inertiatic/esp')
178
eq(list(b.unknowns()), [])
180
def test_subdir_add(self):
181
"""Add in subdirectory should add only things from there down"""
183
from bzrlib.branch import Branch
185
eq = self.assertEqual
189
b = Branch.initialize('.')
191
self.build_tree(['src/', 'README'])
193
eq(sorted(b.unknowns()),
196
self.run_bzr('add', 'src')
198
self.build_tree(['src/foo.c'])
203
eq(sorted(b.unknowns()),
205
eq(len(t.read_working_inventory()), 3)
209
eq(list(b.unknowns()), [])
213
137
def check_branch(self):
214
138
"""After all the above changes, run the check and upgrade commands.