4
4
from bzrlib.add import smart_add, smart_add_tree
5
5
from bzrlib.tests import TestCaseWithTransport, TestCase
6
from bzrlib.branch import Branch
7
from bzrlib.errors import NotBranchError, NoSuchFile
6
from bzrlib.errors import NoSuchFile
8
7
from bzrlib.inventory import InventoryFile, Inventory
9
8
from bzrlib.workingtree import WorkingTree
117
116
branch = wt.branch
118
117
self.assertRaises(NoSuchFile, smart_add_tree, wt, 'non-existant-file')
120
def test_returns(self):
119
def test_returns_and_ignores(self):
121
120
"""Correctly returns added/ignored files"""
122
121
from bzrlib.commands import run_bzr
123
122
wt = self.make_branch_and_tree('.')
124
123
branch = wt.branch
124
# no files should be ignored by default, so we need to create
125
# an ignore rule - we create one for the pyc files, which means
126
# CVS should not be ignored.
125
127
self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
126
128
'inertiatic/foo.pyc'])
129
self.build_tree_contents([('.bzrignore', '*.py[oc]\n')])
127
130
added, ignored = smart_add_tree(wt, u'.')
128
self.assertSubset(('inertiatic', 'inertiatic/esp'), added)
129
self.assertSubset(('CVS', '*.py[oc]'), ignored)
130
self.assertSubset(('inertiatic/CVS',), ignored['CVS'])
131
self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'),
133
self.assertSubset(('*.py[oc]',), ignored)
131
134
self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[oc]'])
134
class TestSmartAddBranch(TestCaseWithTransport):
137
class TestSmartAddTree(TestCaseWithTransport):
135
138
"""Test smart adds with a specified branch."""
137
140
def test_add_dot_from_root(self):