~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_add.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-13 13:03:03 UTC
  • mfrom: (1767.2.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060613130303-e9de5dbda2e80da6
(robertc, abentley, jameinel, mpool)Various improvements to add performance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        wt = self.make_branch_and_tree('.')
60
60
        branch = wt.branch
61
61
        child_tree = self.make_branch_and_tree('original/child')
62
 
        smart_add_tree(wt, (u".",))
 
62
        smart_add_tree(wt, (".",))
63
63
        for path in paths:
64
64
            self.assertNotEqual((path, wt.path2id(path)),
65
65
                                (path, None))
75
75
        paths = ("file1", "file2")
76
76
        self.build_tree(paths)
77
77
        wt = self.make_branch_and_tree('.')
78
 
        branch = wt.branch
79
78
        smart_add_tree(wt, paths)
80
79
        for path in paths:
81
80
            self.assertNotEqual(wt.path2id(path), None)
 
81
    
 
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)
 
92
 
 
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)
82
101
 
83
102
    def test_add_dry_run(self):
84
103
        """Test a dry run add, make sure nothing is added."""
186
205
 
187
206
class TestAddActions(TestCase):
188
207
 
189
 
    def test_null(self):
190
 
        self.run_action("", False)
191
 
 
192
 
    def test_add(self):
193
 
        self.run_action("", True)
194
 
 
195
 
    def test_add_and_print(self):
196
 
        self.run_action("added path\n", True)
197
 
 
198
 
    def test_print(self):
199
 
        self.run_action("added path\n", False)
200
 
 
201
 
    def run_action(self, output, should_add):
202
 
        from bzrlib.add import AddAction
 
208
    def test_quiet(self):
 
209
        self.run_action("")
 
210
 
 
211
    def test__print(self):
 
212
        self.run_action("added path\n")
 
213
 
 
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))
208
220
 
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)
211
 
 
212
 
        if should_add:
213
 
            self.assertNotEqual(inv.path2id('path'), None)
214
 
        else:
215
 
            self.assertEqual(inv.path2id('path'), None)