27
27
def test_add_reports(self):
28
28
"""add command prints the names of added files."""
30
30
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
31
31
self.build_tree_contents([('.bzrignore', 'CVS\n')])
32
out = self.run_bzr('add')[0]
32
out = self.run_bzr_captured(['add'], retcode=0)[0]
33
33
# the ordering is not defined at the moment
34
34
results = sorted(out.rstrip('\n').split('\n'))
35
35
self.assertEquals(['If you wish to add some of these files, please'\
50
50
def test_add_quiet_is(self):
51
51
"""add -q does not print the names of added files."""
53
53
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
54
out = self.run_bzr('add -q')[0]
54
out = self.run_bzr_captured(['add', '-q'], retcode=0)[0]
55
55
# the ordering is not defined at the moment
56
56
results = sorted(out.rstrip('\n').split('\n'))
57
57
self.assertEquals([''], results)
62
62
"bzr add" should add the parent(s) as necessary.
65
65
self.build_tree(['inertiatic/', 'inertiatic/esp'])
66
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
67
self.run_bzr('add inertiatic/esp')
68
self.assertEquals(self.run_bzr('unknowns')[0], '')
66
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
67
self.run_bzr('add', 'inertiatic/esp')
68
self.assertEquals(self.capture('unknowns'), '')
70
70
# Multiple unversioned parents
71
71
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
72
self.assertEquals(self.run_bzr('unknowns')[0], 'veil\n')
73
self.run_bzr('add veil/cerpin/taxt')
74
self.assertEquals(self.run_bzr('unknowns')[0], '')
72
self.assertEquals(self.capture('unknowns'), 'veil\n')
73
self.run_bzr('add', 'veil/cerpin/taxt')
74
self.assertEquals(self.capture('unknowns'), '')
76
76
# Check whacky paths work
77
77
self.build_tree(['cicatriz/', 'cicatriz/esp'])
78
self.assertEquals(self.run_bzr('unknowns')[0], 'cicatriz\n')
79
self.run_bzr('add inertiatic/../cicatriz/esp')
80
self.assertEquals(self.run_bzr('unknowns')[0], '')
78
self.assertEquals(self.capture('unknowns'), 'cicatriz\n')
79
self.run_bzr('add', 'inertiatic/../cicatriz/esp')
80
self.assertEquals(self.capture('unknowns'), '')
82
82
def test_add_in_versioned(self):
83
83
"""Try to add a file in a versioned directory.
85
85
"bzr add" should do this happily.
88
88
self.build_tree(['inertiatic/', 'inertiatic/esp'])
89
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
90
self.run_bzr('add --no-recurse inertiatic')
91
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic/esp\n')
92
self.run_bzr('add inertiatic/esp')
93
self.assertEquals(self.run_bzr('unknowns')[0], '')
89
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
90
self.run_bzr('add', '--no-recurse', 'inertiatic')
91
self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
92
self.run_bzr('add', 'inertiatic/esp')
93
self.assertEquals(self.capture('unknowns'), '')
95
95
def test_subdir_add(self):
96
96
"""Add in subdirectory should add only things from there down"""
125
125
# add from the parent directory should pick up all file names
127
127
self.run_bzr('add')
128
self.assertEquals(self.run_bzr('unknowns')[0], '')
128
self.assertEquals(self.capture('unknowns'), '')
129
129
self.run_bzr('check')
131
131
def test_add_missing(self):
132
132
"""bzr add foo where foo is missing should error."""
133
133
self.make_branch_and_tree('.')
134
self.run_bzr('add missing-file', retcode=3)
134
self.run_bzr('add', 'missing-file', retcode=3)
136
136
def test_add_from(self):
137
137
base_tree = self.make_branch_and_tree('base')
143
143
self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd'])
146
out, err = self.run_bzr('add --file-ids-from ../base')
146
out, err = self.run_bzr('add', '--file-ids-from', '../base')
147
147
self.assertEqual('', err)
148
148
self.assertEqualDiff('added a w/ file id from a\n'
149
149
'added b w/ file id from b\n'
164
164
self.build_tree(['new/c', 'new/d'])
167
out, err = self.run_bzr('add --file-ids-from ../base/b')
167
out, err = self.run_bzr('add', '--file-ids-from', '../base/b')
168
168
self.assertEqual('', err)
169
169
self.assertEqualDiff('added c w/ file id from b/c\n'
170
170
'added d w/ file id from b/d\n',
175
175
self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d'))
177
177
def test_add_dry_run(self):
178
"""Test a dry run add, make sure nothing is added."""
179
wt = self.make_branch_and_tree('.')
180
self.build_tree(['inertiatic/', 'inertiatic/esp'])
181
self.assertEqual(list(wt.unknowns()), ['inertiatic'])
182
self.run_bzr('add --dry-run')
183
self.assertEqual(list(wt.unknowns()), ['inertiatic'])
178
# ensure that --dry-run actually don't add anything
179
base_tree = self.make_branch_and_tree('.')
180
self.build_tree(['spam'])
181
out = self.run_bzr_captured(['add', '--dry-run'], retcode=0)[0]
182
self.assertEquals('added spam\n', out)
183
out = self.run_bzr_captured(['added'], retcode=0)[0]
184
self.assertEquals('', out)
185
186
def test_add_control_dir(self):
186
187
"""The control dir and its content should be refused."""
187
188
self.make_branch_and_tree('.')
188
err = self.run_bzr('add .bzr', retcode=3)[1]
189
err = self.run_bzr('add', '.bzr', retcode=3)[1]
189
190
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
190
err = self.run_bzr('add .bzr/README', retcode=3)[1]
191
err = self.run_bzr('add', '.bzr/README', retcode=3)[1]
191
192
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
192
193
self.build_tree(['.bzr/crescent'])
193
err = self.run_bzr('add .bzr/crescent', retcode=3)[1]
194
err = self.run_bzr('add', '.bzr/crescent', retcode=3)[1]
194
195
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')