28
28
"""add command prints the names of added files."""
29
29
self.runbzr('init')
30
30
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
31
self.build_tree_contents([('.bzrignore', 'CVS\n')])
31
32
out = self.run_bzr_captured(['add'], retcode=0)[0]
32
33
# the ordering is not defined at the moment
33
34
results = sorted(out.rstrip('\n').split('\n'))
34
35
self.assertEquals(['If you wish to add some of these files, please'\
35
36
' add them by name.',
37
39
'added dir/sub.txt',
119
121
self.run_bzr('add')
120
122
self.assertEquals(self.capture('unknowns'), '')
121
123
self.run_bzr('check')
125
def test_add_missing(self):
126
"""bzr add foo where foo is missing should error."""
127
self.make_branch_and_tree('.')
128
self.run_bzr('add', 'missing-file', retcode=3)
130
def test_add_from(self):
131
base_tree = self.make_branch_and_tree('base')
132
self.build_tree(['base/a', 'base/b/', 'base/b/c'])
133
base_tree.add(['a', 'b', 'b/c'])
134
base_tree.commit('foo')
136
new_tree = self.make_branch_and_tree('new')
137
self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd'])
140
out, err = self.run_bzr('add', '--file-ids-from', '../base')
141
self.assertEqual('', err)
142
self.assertEqualDiff('added a w/ file id from a\n'
143
'added b w/ file id from b\n'
144
'added b/c w/ file id from b/c\n',
147
new_tree.read_working_inventory()
148
self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a'))
149
self.assertEqual(base_tree.path2id('b'), new_tree.path2id('b'))
150
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('b/c'))
152
def test_add_from_subdir(self):
153
base_tree = self.make_branch_and_tree('base')
154
self.build_tree(['base/a', 'base/b/', 'base/b/c', 'base/b/d'])
155
base_tree.add(['a', 'b', 'b/c', 'b/d'])
156
base_tree.commit('foo')
158
new_tree = self.make_branch_and_tree('new')
159
self.build_tree(['new/c', 'new/d'])
162
out, err = self.run_bzr('add', '--file-ids-from', '../base/b')
163
self.assertEqual('', err)
164
self.assertEqualDiff('added c w/ file id from b/c\n'
165
'added d w/ file id from b/d\n',
168
new_tree.read_working_inventory()
169
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('c'))
170
self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d'))
172
def test_add_dry_run(self):
173
# ensure that --dry-run actually don't add anything
174
base_tree = self.make_branch_and_tree('.')
175
self.build_tree(['spam'])
176
out = self.run_bzr_captured(['add', '--dry-run'], retcode=0)[0]
177
self.assertEquals('added spam\n', out)
178
out = self.run_bzr_captured(['added'], retcode=0)[0]
179
self.assertEquals('', out)