136
136
"""bzr add foo where foo is missing should error."""
137
137
self.make_branch_and_tree('.')
138
138
self.run_bzr('add', 'missing-file', retcode=3)
140
def test_add_from(self):
141
base_tree = self.make_branch_and_tree('base')
142
self.build_tree(['base/a', 'base/b/', 'base/b/c'])
143
base_tree.add(['a', 'b', 'b/c'])
144
base_tree.commit('foo')
146
new_tree = self.make_branch_and_tree('new')
147
self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd'])
150
out, err = self.run_bzr('add', '--file-ids-from', '../base')
151
self.assertEqual('', err)
152
self.assertEqualDiff('added a w/ file id from a\n'
153
'added b w/ file id from b\n'
154
'added b/c w/ file id from b/c\n',
157
new_tree.read_working_inventory()
158
self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a'))
159
self.assertEqual(base_tree.path2id('b'), new_tree.path2id('b'))
160
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('b/c'))
162
def test_add_from_subdir(self):
163
base_tree = self.make_branch_and_tree('base')
164
self.build_tree(['base/a', 'base/b/', 'base/b/c', 'base/b/d'])
165
base_tree.add(['a', 'b', 'b/c', 'b/d'])
166
base_tree.commit('foo')
168
new_tree = self.make_branch_and_tree('new')
169
self.build_tree(['new/c', 'new/d'])
172
out, err = self.run_bzr('add', '--file-ids-from', '../base/b')
173
self.assertEqual('', err)
174
self.assertEqualDiff('added c w/ file id from b/c\n'
175
'added d w/ file id from b/d\n',
178
new_tree.read_working_inventory()
179
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('c'))
180
self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d'))
182
def test_add_dry_run(self):
183
# ensure that --dry-run actually don't add anything
184
base_tree = self.make_branch_and_tree('.')
185
self.build_tree(['spam'])
186
out = self.run_bzr_captured(['add', '--dry-run'], retcode=0)[0]
187
self.assertEquals('added spam\n', out)
188
out = self.run_bzr_captured(['added'], retcode=0)[0]
189
self.assertEquals('', out)