4
from bzrlib import errors, osutils
4
from bzrlib import errors, ignores, osutils
5
5
from bzrlib.add import smart_add, smart_add_tree
6
6
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
7
7
from bzrlib.errors import NoSuchFile
99
99
def test_add_dry_run(self):
100
100
"""Test a dry run add, make sure nothing is added."""
101
101
from bzrlib.commands import run_bzr
102
ignores._set_user_ignores(['./.bazaar'])
102
103
eq = self.assertEqual
103
104
wt = self.make_branch_and_tree('.')
104
105
self.build_tree(['inertiatic/', 'inertiatic/esp'])
116
117
"""Correctly returns added/ignored files"""
117
118
from bzrlib.commands import run_bzr
118
119
wt = self.make_branch_and_tree('.')
119
# no files should be ignored by default, so we need to create
120
# an ignore rule - we create one for the pyc files, which means
121
# CVS should not be ignored.
122
self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
120
# The default ignore list includes '*.py[co]', but not CVS
121
ignores._set_user_ignores(['./.bazaar', '*.py[co]'])
122
self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
123
123
'inertiatic/foo.pyc'])
124
self.build_tree_contents([('.bzrignore', '*.py[oc]\n')])
125
124
added, ignored = smart_add_tree(wt, u'.')
126
125
self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'),
128
self.assertSubset(('*.py[oc]',), ignored)
129
self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[oc]'])
127
self.assertSubset(('*.py[co]',), ignored)
128
self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[co]'])
132
131
class TestSmartAddTree(TestCaseWithTransport):
229
228
osutils.normalized_filename = osutils._accessible_normalized_filename
231
230
smart_add_tree(self.wt, [u'a\u030a'])
232
self.assertEqual([(u'\xe5', 'file')],
231
self.assertEqual([('', 'root_directory'), (u'\xe5', 'file')],
233
232
[(path, ie.kind) for path,ie in
234
233
self.wt.inventory.iter_entries()])
241
240
osutils.normalized_filename = osutils._accessible_normalized_filename
243
242
smart_add_tree(self.wt, [])
244
self.assertEqual([(u'\xe5', 'file')],
243
self.assertEqual([('', 'root_directory'), (u'\xe5', 'file')],
245
244
[(path, ie.kind) for path,ie in
246
245
self.wt.inventory.iter_entries()])