~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_add.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
import unittest
3
3
 
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'),
127
126
                          added)
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]'])
130
129
 
131
130
 
132
131
class TestSmartAddTree(TestCaseWithTransport):
229
228
        osutils.normalized_filename = osutils._accessible_normalized_filename
230
229
        try:
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()])
235
234
        finally:
241
240
        osutils.normalized_filename = osutils._accessible_normalized_filename
242
241
        try:
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()])
247
246
        finally: