59
59
wt = self.make_branch_and_tree('.')
61
61
child_tree = self.make_branch_and_tree('original/child')
62
smart_add_tree(wt, (u".",))
62
smart_add_tree(wt, (".",))
64
64
self.assertNotEqual((path, wt.path2id(path)),
75
75
paths = ("file1", "file2")
76
76
self.build_tree(paths)
77
77
wt = self.make_branch_and_tree('.')
79
78
smart_add_tree(wt, paths)
81
80
self.assertNotEqual(wt.path2id(path), None)
82
def test_add_ignored_nested_paths(self):
83
"""Test smart-adding a list of paths which includes ignored ones."""
84
wt = self.make_branch_and_tree('.')
85
tree_shape = ("adir/", "adir/CVS/", "adir/CVS/afile", "adir/CVS/afile2")
86
add_paths = ("adir/CVS", "adir/CVS/afile", "adir")
87
expected_paths = ("adir", "adir/CVS", "adir/CVS/afile", "adir/CVS/afile2")
88
self.build_tree(tree_shape)
89
smart_add_tree(wt, add_paths)
90
for path in expected_paths:
91
self.assertNotEqual(wt.path2id(path), None, "No id added for %s" % path)
93
def test_save_false(self):
94
"""Test smart-adding a path with save set to false."""
95
wt = self.make_branch_and_tree('.')
96
self.build_tree(['file'])
97
smart_add_tree(wt, ['file'], save=False)
98
self.assertNotEqual(wt.path2id('file'), None, "No id added for 'file'")
99
wt.read_working_inventory()
100
self.assertEqual(wt.path2id('file'), None)
83
102
def test_add_dry_run(self):
84
103
"""Test a dry run add, make sure nothing is added."""
187
206
class TestAddActions(TestCase):
190
self.run_action("", False)
193
self.run_action("", True)
195
def test_add_and_print(self):
196
self.run_action("added path\n", True)
198
def test_print(self):
199
self.run_action("added path\n", False)
201
def run_action(self, output, should_add):
202
from bzrlib.add import AddAction
208
def test_quiet(self):
211
def test__print(self):
212
self.run_action("added path\n")
214
def run_action(self, output):
215
from bzrlib.add import AddAction, FastPath
203
216
from cStringIO import StringIO
204
217
inv = Inventory()
205
218
stdout = StringIO()
206
action = AddAction(to_file=stdout,
207
should_print=bool(output), should_add=should_add)
219
action = AddAction(to_file=stdout, should_print=bool(output))
209
self.apply_redirected(None, stdout, None, action, inv, None, 'path', 'file')
221
self.apply_redirected(None, stdout, None, action, inv, None, FastPath('path'), 'file')
210
222
self.assertEqual(stdout.getvalue(), output)
213
self.assertNotEqual(inv.path2id('path'), None)
215
self.assertEqual(inv.path2id('path'), None)