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