113
114
self.assertEquals(delta.added[0][0], 'dir')
114
115
self.failIf(delta.modified)
116
def test_branch_add_in_unversioned(self):
117
def test_working_tree_add_in_unversioned(self):
117
118
"""Try to add a file in an unversioned directory.
119
"bzr add" adds the parent as necessary, but simple branch add
120
"bzr add" adds the parent as necessary, but simple working tree add
122
123
from bzrlib.branch import Branch
123
124
from bzrlib.errors import NotVersionedError
125
from bzrlib.workingtree import WorkingTree
125
b = Branch.initialize('.')
127
b = Branch.initialize(u'.')
127
129
self.build_tree(['foo/',
130
132
self.assertRaises(NotVersionedError,
133
WorkingTree(b.base, b).add,
134
136
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
138
def check_branch(self):
214
139
"""After all the above changes, run the check and upgrade commands.
216
141
The upgrade should be a no-op."""
142
b = Branch.open(u'.')
218
143
mutter('branch has %d revisions', b.revno())
220
145
mutter('check branch...')