/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2007, 2009-2012, 2016 Canonical Ltd
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
16
17
"""Test that we can use smart_add on all Tree implementations."""
18
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
19
import os
4789.11.1 by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows.
20
import sys
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
21
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
22
from ... import (
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
23
    errors,
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
24
    ignores,
25
    osutils,
2568.2.10 by Robert Collins
And a missing import.
26
    tests,
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
27
    trace,
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
28
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
29
from ...sixish import (
6621.22.2 by Martin
Use BytesIO or StringIO from bzrlib.sixish
30
    BytesIO,
31
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
32
from .. import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
33
    features,
34
    per_workingtree,
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
35
    test_smart_add,
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
36
    )
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
37
38
39
class TestSmartAddTree(per_workingtree.TestCaseWithWorkingTree):
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
40
41
    def test_single_file(self):
42
        tree = self.make_branch_and_tree('tree')
43
        self.build_tree(['tree/a'])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
44
        tree.smart_add(['tree'])
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
45
46
        tree.lock_read()
47
        try:
48
            files = [(path, status, kind)
49
                     for path, status, kind, file_id, parent_id
50
                      in tree.list_files(include_root=True)]
51
        finally:
52
            tree.unlock()
53
        self.assertEqual([('', 'V', 'directory'), ('a', 'V', 'file')],
54
                         files)
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
55
4634.55.1 by Robert Collins
Do not add files whose name contains new lines or carriage returns
56
    def assertFilenameSkipped(self, filename):
57
        tree = self.make_branch_and_tree('tree')
4789.11.1 by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows.
58
        try:
59
            self.build_tree(['tree/'+filename])
60
        except errors.NoSuchFile:
61
            if sys.platform == 'win32':
62
                raise tests.TestNotApplicable('Cannot create files named %r on'
63
                    ' win32' % (filename,))
4634.55.1 by Robert Collins
Do not add files whose name contains new lines or carriage returns
64
        tree.smart_add(['tree'])
65
        self.assertEqual(None, tree.path2id(filename))
66
67
    def test_path_containing_newline_skips(self):
68
        self.assertFilenameSkipped('a\nb')
69
70
    def test_path_containing_carriagereturn_skips(self):
71
        self.assertFilenameSkipped('a\rb')
72
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
73
    def test_save_false(self):
74
        """Dry-run add doesn't permanently affect the tree."""
75
        wt = self.make_branch_and_tree('.')
2585.1.1 by Aaron Bentley
Unify MutableTree.smart_add behavior by disabling quirky memory-only Inventory
76
        wt.lock_write()
77
        try:
78
            self.build_tree(['file'])
79
            wt.smart_add(['file'], save=False)
80
            # the file should not be added - no id.
81
            self.assertEqual(wt.path2id('file'), None)
82
        finally:
83
            wt.unlock()
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
84
        # and the disk state should be the same - reopen to check.
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
85
        wt = wt.controldir.open_workingtree()
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
86
        self.assertEqual(wt.path2id('file'), None)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
87
88
    def test_add_dot_from_root(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
89
        """Test adding . from the root of the tree."""
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
90
        paths = ("original/", "original/file1", "original/file2")
91
        self.build_tree(paths)
92
        wt = self.make_branch_and_tree('.')
93
        wt.smart_add((u".",))
94
        for path in paths:
95
            self.assertNotEqual(wt.path2id(path), None)
96
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
97
    def test_skip_nested_trees(self):
98
        """Test smart-adding a nested tree ignors it and warns."""
99
        wt = self.make_branch_and_tree('.')
100
        nested_wt = self.make_branch_and_tree('nested')
101
        warnings = []
102
        def warning(*args):
103
            warnings.append(args[0] % args[1:])
104
        self.overrideAttr(trace, 'warning', warning)
105
        wt.smart_add((u".",))
106
        self.assertIs(wt.path2id("nested"), None)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
107
        self.assertEqual(
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
108
            ['skipping nested tree %r' % nested_wt.basedir], warnings)
109
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
110
    def test_add_dot_from_subdir(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
111
        """Test adding . from a subdir of the tree."""
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
112
        paths = ("original/", "original/file1", "original/file2")
113
        self.build_tree(paths)
114
        wt = self.make_branch_and_tree('.')
115
        wt.smart_add((u".",))
116
        for path in paths:
117
            self.assertNotEqual(wt.path2id(path), None)
118
119
    def test_add_tree_from_above_tree(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
120
        """Test adding a tree from above the tree."""
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
121
        paths = ("original/", "original/file1", "original/file2")
122
        branch_paths = ("branch/", "branch/original/", "branch/original/file1",
123
                        "branch/original/file2")
124
        self.build_tree(branch_paths)
125
        wt = self.make_branch_and_tree('branch')
126
        wt.smart_add(("branch",))
127
        for path in paths:
128
            self.assertNotEqual(wt.path2id(path), None)
129
130
    def test_add_above_tree_preserves_tree(self):
131
        """Test nested trees are not affect by an add above them."""
132
        paths = ("original/", "original/file1", "original/file2")
133
        child_paths = ("path",)
134
        full_child_paths = ("original/child", "original/child/path")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
135
        build_paths = ("original/", "original/file1", "original/file2",
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
136
                       "original/child/", "original/child/path")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
137
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
138
        self.build_tree(build_paths)
139
        wt = self.make_branch_and_tree('.')
6437.70.6 by John Arbash Meinel
Fix a couple tests that wanted to directly create a wt where the branch was.
140
        if wt.user_url != wt.branch.user_url:
141
            # Lightweight checkout, make sure we have a repo location.
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
142
            wt.branch.controldir.root_transport.mkdir('original')
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
143
        child_tree = self.make_branch_and_tree('original/child')
144
        wt.smart_add((".",))
145
        for path in paths:
146
            self.assertNotEqual((path, wt.path2id(path)),
147
                                (path, None))
148
        for path in full_child_paths:
149
            self.assertEqual((path, wt.path2id(path)),
150
                             (path, None))
151
        for path in child_paths:
152
            self.assertEqual(child_tree.path2id(path), None)
153
154
    def test_add_paths(self):
155
        """Test smart-adding a list of paths."""
156
        paths = ("file1", "file2")
157
        self.build_tree(paths)
158
        wt = self.make_branch_and_tree('.')
159
        wt.smart_add(paths)
160
        for path in paths:
161
            self.assertNotEqual(wt.path2id(path), None)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
162
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
163
    def test_add_ignored_nested_paths(self):
164
        """Test smart-adding a list of paths which includes ignored ones."""
165
        wt = self.make_branch_and_tree('.')
166
        tree_shape = ("adir/", "adir/CVS/", "adir/CVS/afile", "adir/CVS/afile2")
167
        add_paths = ("adir/CVS", "adir/CVS/afile", "adir")
168
        expected_paths = ("adir", "adir/CVS", "adir/CVS/afile", "adir/CVS/afile2")
169
        self.build_tree(tree_shape)
170
        wt.smart_add(add_paths)
171
        for path in expected_paths:
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
172
            self.assertNotEqual(wt.path2id(path), None,
173
                "No id added for %s" % path)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
174
175
    def test_add_non_existant(self):
176
        """Test smart-adding a file that does not exist."""
177
        wt = self.make_branch_and_tree('.')
178
        self.assertRaises(errors.NoSuchFile, wt.smart_add, ['non-existant-file'])
179
180
    def test_returns_and_ignores(self):
181
        """Correctly returns added/ignored files"""
182
        wt = self.make_branch_and_tree('.')
183
        # The default ignore list includes '*.py[co]', but not CVS
184
        ignores._set_user_ignores(['*.py[co]'])
185
        self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
186
                        'inertiatic/foo.pyc'])
187
        added, ignored = wt.smart_add(u'.')
188
        self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'),
189
                          added)
190
        self.assertSubset(('*.py[co]',), ignored)
191
        self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[co]'])
192
193
    def test_add_multiple_dirs(self):
194
        """Test smart adding multiple directories at once."""
195
        added_paths = ['file1', 'file2',
196
                       'dir1/', 'dir1/file3',
197
                       'dir1/subdir2/', 'dir1/subdir2/file4',
198
                       'dir2/', 'dir2/file5',
199
                      ]
200
        not_added = ['file6', 'dir3/', 'dir3/file7', 'dir3/file8']
201
        self.build_tree(added_paths)
202
        self.build_tree(not_added)
203
204
        wt = self.make_branch_and_tree('.')
205
        wt.smart_add(['file1', 'file2', 'dir1', 'dir2'])
206
207
        for path in added_paths:
208
            self.assertNotEqual(None, wt.path2id(path.rstrip('/')),
209
                    'Failed to add path: %s' % (path,))
210
        for path in not_added:
211
            self.assertEqual(None, wt.path2id(path.rstrip('/')),
212
                    'Accidentally added path: %s' % (path,))
213
4163.2.1 by Ian Clatworthy
Fix add in trees supports views
214
    def test_add_file_in_unknown_dir(self):
215
        # Test that parent directory addition is implicit
216
        tree = self.make_branch_and_tree('.')
217
        self.build_tree(['dir/', 'dir/subdir/', 'dir/subdir/foo'])
218
        tree.smart_add(['dir/subdir/foo'])
219
        tree.lock_read()
220
        self.addCleanup(tree.unlock)
221
        self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'],
222
            [path for path, ie in tree.iter_entries_by_dir()])
223
5504.6.2 by Martin
If a dir being added used to be something else detect and correct
224
    def test_add_dir_bug_251864(self):
5504.6.3 by Martin
Address poolie's review, mention both bugs in test and add news
225
        """Added file turning into a dir should be detected on add dir
226
227
        Similar to bug 205636 but with automatic adding of directory contents.
228
        """
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
229
        tree = self.make_branch_and_tree(".")
230
        self.build_tree(["dir"]) # whoops, make a file called dir
231
        tree.smart_add(["dir"])
232
        os.remove("dir")
233
        self.build_tree(["dir/", "dir/file"])
5504.6.2 by Martin
If a dir being added used to be something else detect and correct
234
        tree.smart_add(["dir"])
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
235
        tree.commit("Add dir contents")
5378.1.4 by Martin
Assert state of the tree after add and commit in new tests
236
        self.addCleanup(tree.lock_read().unlock)
237
        self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")],
238
            [(t[0], t[2]) for t in tree.list_files()])
239
        self.assertFalse(list(tree.iter_changes(tree.basis_tree())))
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
240
241
    def test_add_subdir_file_bug_205636(self):
242
        """Added file turning into a dir should be detected on add dir/file"""
243
        tree = self.make_branch_and_tree(".")
244
        self.build_tree(["dir"]) # whoops, make a file called dir
245
        tree.smart_add(["dir"])
246
        os.remove("dir")
247
        self.build_tree(["dir/", "dir/file"])
5378.1.3 by Martin
Note that TestSmartAddTree.test_add_subdir_file_bug_205636 now passes
248
        tree.smart_add(["dir/file"])
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
249
        tree.commit("Add file in dir")
5378.1.4 by Martin
Assert state of the tree after add and commit in new tests
250
        self.addCleanup(tree.lock_read().unlock)
251
        self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")],
252
            [(t[0], t[2]) for t in tree.list_files()])
253
        self.assertFalse(list(tree.iter_changes(tree.basis_tree())))
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
254
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
255
    def test_custom_ids(self):
6621.22.2 by Martin
Use BytesIO or StringIO from bzrlib.sixish
256
        sio = BytesIO()
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
257
        action = test_smart_add.AddCustomIDAction(to_file=sio,
258
                                                  should_print=True)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
259
        self.build_tree(['file1', 'dir1/', 'dir1/file2'])
260
261
        wt = self.make_branch_and_tree('.')
262
        wt.smart_add(['.'], action=action)
263
        # The order of adds is not strictly fixed:
264
        sio.seek(0)
265
        lines = sorted(sio.readlines())
3985.2.5 by Daniel Watkins
Reverted some irrelevant changes.
266
        self.assertEqualDiff(['added dir1 with id directory-dir1\n',
267
                              'added dir1/file2 with id file-dir1%file2\n',
268
                              'added file1 with id file-file1\n',
269
                             ], lines)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
270
        wt.lock_read()
271
        self.addCleanup(wt.unlock)
272
        self.assertEqual([('', wt.path2id('')),
273
                          ('dir1', 'directory-dir1'),
5807.1.8 by Jelmer Vernooij
Fix some tests.
274
                          ('file1', 'file-file1'),
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
275
                          ('dir1/file2', 'file-dir1%file2'),
276
                         ], [(path, ie.file_id) for path, ie
5807.1.8 by Jelmer Vernooij
Fix some tests.
277
                                in wt.iter_entries_by_dir()])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
278
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
279
5013.2.4 by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files.
280
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
281
282
    def make_tree_with_text_conflict(self):
283
        tb = self.make_branch_and_tree('base')
284
        self.build_tree_contents([('base/file', 'content in base')])
285
        tb.add('file')
286
        tb.commit('Adding file')
287
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
288
        t1 = tb.controldir.sprout('t1').open_workingtree()
5013.2.4 by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files.
289
290
        self.build_tree_contents([('base/file', 'content changed in base')])
291
        tb.commit('Changing file in base')
292
293
        self.build_tree_contents([('t1/file', 'content in t1')])
294
        t1.commit('Changing file in t1')
295
        t1.merge_from_branch(tb.branch)
296
        return t1
297
298
    def test_cant_add_generated_files_implicitly(self):
299
        t = self.make_tree_with_text_conflict()
300
        added, ignored = t.smart_add([t.basedir])
301
        self.assertEqual(([], {}), (added, ignored))
302
303
    def test_can_add_generated_files_explicitly(self):
304
        fnames = ['file.%s' % s  for s in ('BASE', 'THIS', 'OTHER')]
305
        t = self.make_tree_with_text_conflict()
306
        added, ignored = t.smart_add([t.basedir + '/%s' % f for f in fnames])
307
        self.assertEqual((fnames, {}), (added, ignored))
308
309
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
310
class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree):
311
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
312
    _test_needs_features = [features.UnicodeFilenameFeature]
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
313
314
    def setUp(self):
315
        super(TestSmartAddTreeUnicode, self).setUp()
316
        self.build_tree([u'a\u030a'])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
317
        self.wt = self.make_branch_and_tree('.')
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
318
        self.overrideAttr(osutils, 'normalized_filename')
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
319
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
320
    def test_requires_normalized_unicode_filenames_fails_on_unnormalized(self):
321
        """Adding unnormalized unicode filenames fail if and only if the
322
        workingtree format has the requires_normalized_unicode_filenames flag
5929.1.1 by Vincent Ladeuil
Fix spurious test failure on OSX for WorkingTreeFormat2
323
        set and the underlying filesystem doesn't normalize.
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
324
        """
325
        osutils.normalized_filename = osutils._accessible_normalized_filename
5929.1.1 by Vincent Ladeuil
Fix spurious test failure on OSX for WorkingTreeFormat2
326
        if (self.workingtree_format.requires_normalized_unicode_filenames
327
            and sys.platform != 'darwin'):
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
328
            self.assertRaises(
329
                errors.NoSuchFile, self.wt.smart_add, [u'a\u030a'])
330
        else:
331
            self.wt.smart_add([u'a\u030a'])
332
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
333
    def test_accessible_explicit(self):
334
        osutils.normalized_filename = osutils._accessible_normalized_filename
5582.10.29 by Jelmer Vernooij
Add requires_normalized_unicode_filenames
335
        if self.workingtree_format.requires_normalized_unicode_filenames:
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
336
            raise tests.TestNotApplicable(
337
                'Working tree format smart_add requires normalized unicode '
338
                'filenames')
5868.1.1 by Martin
Turn two long-standing unexpected successes into skips
339
        self.wt.smart_add([u'a\u030a'])
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
340
        self.wt.lock_read()
341
        self.addCleanup(self.wt.unlock)
342
        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
343
                         [(path, ie.kind) for path, ie in
5807.1.8 by Jelmer Vernooij
Fix some tests.
344
                          self.wt.iter_entries_by_dir()])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
345
346
    def test_accessible_implicit(self):
347
        osutils.normalized_filename = osutils._accessible_normalized_filename
5582.10.29 by Jelmer Vernooij
Add requires_normalized_unicode_filenames
348
        if self.workingtree_format.requires_normalized_unicode_filenames:
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
349
            raise tests.TestNotApplicable(
350
                'Working tree format smart_add requires normalized unicode '
351
                'filenames')
5868.1.1 by Martin
Turn two long-standing unexpected successes into skips
352
        self.wt.smart_add([])
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
353
        self.wt.lock_read()
354
        self.addCleanup(self.wt.unlock)
355
        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
356
                         [(path, ie.kind) for path, ie
5807.1.8 by Jelmer Vernooij
Fix some tests.
357
                          in self.wt.iter_entries_by_dir()])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
358
359
    def test_inaccessible_explicit(self):
360
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
361
        self.assertRaises(errors.InvalidNormalization,
362
                          self.wt.smart_add, [u'a\u030a'])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
363
364
    def test_inaccessible_implicit(self):
365
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
366
        # TODO: jam 20060701 In the future, this should probably
367
        #       just ignore files that don't fit the normalization
368
        #       rules, rather than exploding
369
        self.assertRaises(errors.InvalidNormalization, self.wt.smart_add, [])