~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree_4.py

  • Committer: John Arbash Meinel
  • Date: 2008-03-17 20:11:30 UTC
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080317201130-254scn9jqanfvc92
Raise a clear error about the offending filename when there is a filename with bad characters.
Related to bug #77657

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    errors,
26
26
    inventory,
27
27
    osutils,
 
28
    tests,
28
29
    workingtree_4,
29
30
    )
30
31
from bzrlib.lockdir import LockDir
670
671
            ('', [(('', 'dir', 'dir-id'), ['d', 'd'])]),
671
672
            ('dir', [(('dir', 'file', 'file-id'), ['a', 'f'])]),
672
673
        ],  self.get_simple_dirblocks(state))
 
674
 
 
675
 
 
676
class TestIllegalPaths(TestCaseWithTransport):
 
677
 
 
678
    def test_bad_fs_path(self):
 
679
        self.requireFeature(tests.UTF8Filesystem)
 
680
        # We require a UTF8 filesystem, because otherwise we would need to get
 
681
        # tricky to figure out how to create an illegal filename.
 
682
        # \xb5 is an illegal path because it should be \xc2\xb5 for UTF-8
 
683
        tree = self.make_branch_and_tree('tree')
 
684
        self.build_tree(['tree/subdir/'])
 
685
        tree.add('subdir')
 
686
 
 
687
        f = open('tree/subdir/m\xb5', 'wb')
 
688
        try:
 
689
            f.write('trivial\n')
 
690
        finally:
 
691
            f.close()
 
692
 
 
693
        tree.lock_read()
 
694
        self.addCleanup(tree.unlock)
 
695
        basis = tree.basis_tree()
 
696
        basis.lock_read()
 
697
        self.addCleanup(basis.unlock)
 
698
 
 
699
        e = self.assertListRaises(errors.BadFilenameEncoding,
 
700
                                  tree.iter_changes, tree.basis_tree(),
 
701
                                                     want_unversioned=True)
 
702
        # We should display the relative path
 
703
        self.assertEqual('subdir/m\xb5', e.filename)
 
704
        self.assertEqual(osutils._fs_enc, e.fs_encoding)