13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
"""Tests of the 'bzr add' command."""
22
from bzrlib.tests import (
24
split_suite_by_condition,
27
22
from bzrlib.tests.blackbox import ExternalBase
28
23
from bzrlib.tests.test_win32utils import NeedsGlobExpansionFeature
31
def load_tests(standard_tests, module, loader):
32
"""Parameterize tests for view-aware vs not."""
33
to_adapt, result = split_suite_by_condition(
34
standard_tests, condition_isinstance(TestAdd))
36
('pre-views', {'branch_tree_format': 'pack-0.92'}),
37
('view-aware', {'branch_tree_format': 'development-wt6'}),
39
return multiply_tests(to_adapt, scenarios, result)
42
26
class TestAdd(ExternalBase):
44
def make_branch_and_tree(self, dir):
45
return ExternalBase.make_branch_and_tree(self, dir,
46
format=self.branch_tree_format)
48
28
def test_add_reports(self):
49
29
"""add command prints the names of added files."""
50
tree = self.make_branch_and_tree('.')
51
31
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
52
32
self.build_tree_contents([('.bzrignore', 'CVS\n')])
53
33
out = self.run_bzr('add')[0]
71
51
def test_add_quiet_is(self):
72
52
"""add -q does not print the names of added files."""
73
tree = self.make_branch_and_tree('.')
74
54
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
75
55
out = self.run_bzr('add -q')[0]
76
56
# the ordering is not defined at the moment
83
63
"bzr add" should add the parent(s) as necessary.
85
tree = self.make_branch_and_tree('.')
86
66
self.build_tree(['inertiatic/', 'inertiatic/esp'])
87
67
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
88
68
self.run_bzr('add inertiatic/esp')
106
86
"bzr add" should do this happily.
108
tree = self.make_branch_and_tree('.')
109
89
self.build_tree(['inertiatic/', 'inertiatic/esp'])
110
90
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
111
91
self.run_bzr('add --no-recurse inertiatic')
120
100
eq = self.assertEqual
121
101
ass = self.assertTrue
124
104
t = self.make_branch_and_tree('.')
126
106
self.build_tree(['src/', 'README'])
128
108
eq(sorted(t.unknowns()),
129
109
['README', 'src'])
131
111
self.run_bzr('add src')
133
113
self.build_tree(['src/foo.c'])
135
115
# add with no arguments in a subdirectory gets only files below that
142
122
versioned = [path for path, entry in t.iter_entries_by_dir()]
143
123
self.assertEquals(versioned,
144
124
['', 'src', 'src/foo.c'])
146
126
# add from the parent directory should pick up all file names
148
128
self.run_bzr('add')
167
147
out, err = self.run_bzr('add --file-ids-from ../base')
168
148
self.assertEqual('', err)
169
self.assertEqualDiff('adding a w/ file id from a\n'
170
'adding b w/ file id from b\n'
171
'adding b/c w/ file id from b/c\n',
149
self.assertEqualDiff('added a w/ file id from a\n'
150
'added b w/ file id from b\n'
151
'added b/c w/ file id from b/c\n',
173
153
new_tree = new_tree.bzrdir.open_workingtree()
174
154
self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a'))
188
168
out, err = self.run_bzr('add --file-ids-from ../base/b')
189
169
self.assertEqual('', err)
190
self.assertEqualDiff('adding c w/ file id from b/c\n'
191
'adding d w/ file id from b/d\n',
170
self.assertEqualDiff('added c w/ file id from b/c\n'
171
'added d w/ file id from b/d\n',
194
174
new_tree = new_tree.bzrdir.open_workingtree()