~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_smart_add.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import sys
22
22
 
23
23
from bzrlib import (
24
 
    add,
25
24
    errors,
26
25
    ignores,
27
26
    osutils,
28
27
    tests,
29
 
    workingtree,
30
28
    )
31
29
from bzrlib.tests import (
32
 
    features,
33
30
    test_smart_add,
34
31
    per_workingtree,
35
32
    )
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()])
260
257
 
261
258
 
262
259
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
299
296
        self.wt = self.make_branch_and_tree('.')
300
297
        self.overrideAttr(osutils, 'normalized_filename')
301
298
 
 
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.
 
303
        """
 
304
        osutils.normalized_filename = osutils._accessible_normalized_filename
 
305
        if (self.workingtree_format.requires_normalized_unicode_filenames
 
306
            and sys.platform != 'darwin'):
 
307
            self.assertRaises(
 
308
                errors.NoSuchFile, self.wt.smart_add, [u'a\u030a'])
 
309
        else:
 
310
            self.wt.smart_add([u'a\u030a'])
 
311
 
302
312
    def test_accessible_explicit(self):
303
313
        osutils.normalized_filename = osutils._accessible_normalized_filename
304
 
        if isinstance(self.workingtree_format, workingtree.WorkingTreeFormat2):
305
 
            self.expectFailure(
306
 
                'With WorkingTreeFormat2, smart_add requires'
307
 
                ' normalized unicode filenames',
308
 
                self.assertRaises, errors.NoSuchFile,
309
 
                self.wt.smart_add, [u'a\u030a'])
310
 
        else:
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 '
 
317
                'filenames')
 
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()])
317
324
 
318
325
    def test_accessible_implicit(self):
319
326
        osutils.normalized_filename = osutils._accessible_normalized_filename
320
 
        if isinstance(self.workingtree_format, workingtree.WorkingTreeFormat2):
321
 
            self.expectFailure(
322
 
                'With WorkingTreeFormat2, smart_add requires'
323
 
                ' normalized unicode filenames',
324
 
                self.assertRaises, errors.NoSuchFile,
325
 
                self.wt.smart_add, [])
326
 
        else:
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 '
 
330
                'filenames')
 
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()])
333
337
 
334
338
    def test_inaccessible_explicit(self):
335
339
        osutils.normalized_filename = osutils._inaccessible_normalized_filename