253
250
self.addCleanup(wt.unlock)
254
251
self.assertEqual([('', wt.path2id('')),
255
252
('dir1', 'directory-dir1'),
253
('file1', 'file-file1'),
256
254
('dir1/file2', 'file-dir1%file2'),
257
('file1', 'file-file1'),
258
255
], [(path, ie.file_id) for path, ie
259
in wt.inventory.iter_entries()])
256
in wt.iter_entries_by_dir()])
262
259
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
299
296
self.wt = self.make_branch_and_tree('.')
300
297
self.overrideAttr(osutils, 'normalized_filename')
299
def test_requires_normalized_unicode_filenames_fails_on_unnormalized(self):
300
"""Adding unnormalized unicode filenames fail if and only if the
301
workingtree format has the requires_normalized_unicode_filenames flag
302
set and the underlying filesystem doesn't normalize.
304
osutils.normalized_filename = osutils._accessible_normalized_filename
305
if (self.workingtree_format.requires_normalized_unicode_filenames
306
and sys.platform != 'darwin'):
308
errors.NoSuchFile, self.wt.smart_add, [u'a\u030a'])
310
self.wt.smart_add([u'a\u030a'])
302
312
def test_accessible_explicit(self):
303
313
osutils.normalized_filename = osutils._accessible_normalized_filename
304
if isinstance(self.workingtree_format, workingtree.WorkingTreeFormat2):
306
'With WorkingTreeFormat2, smart_add requires'
307
' normalized unicode filenames',
308
self.assertRaises, errors.NoSuchFile,
309
self.wt.smart_add, [u'a\u030a'])
311
self.wt.smart_add([u'a\u030a'])
314
if self.workingtree_format.requires_normalized_unicode_filenames:
315
raise tests.TestNotApplicable(
316
'Working tree format smart_add requires normalized unicode '
318
self.wt.smart_add([u'a\u030a'])
312
319
self.wt.lock_read()
313
320
self.addCleanup(self.wt.unlock)
314
321
self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
315
322
[(path, ie.kind) for path,ie in
316
self.wt.inventory.iter_entries()])
323
self.wt.iter_entries_by_dir()])
318
325
def test_accessible_implicit(self):
319
326
osutils.normalized_filename = osutils._accessible_normalized_filename
320
if isinstance(self.workingtree_format, workingtree.WorkingTreeFormat2):
322
'With WorkingTreeFormat2, smart_add requires'
323
' normalized unicode filenames',
324
self.assertRaises, errors.NoSuchFile,
325
self.wt.smart_add, [])
327
self.wt.smart_add([])
327
if self.workingtree_format.requires_normalized_unicode_filenames:
328
raise tests.TestNotApplicable(
329
'Working tree format smart_add requires normalized unicode '
331
self.wt.smart_add([])
328
332
self.wt.lock_read()
329
333
self.addCleanup(self.wt.unlock)
330
334
self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
331
335
[(path, ie.kind) for path,ie
332
in self.wt.inventory.iter_entries()])
336
in self.wt.iter_entries_by_dir()])
334
338
def test_inaccessible_explicit(self):
335
339
osutils.normalized_filename = osutils._inaccessible_normalized_filename