/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2008-07-21 07:48:30 UTC
  • mfrom: (3564 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3566.
  • Revision ID: mbp@sourcefrog.net-20080721074830-i1pgj2hswpfo6pav
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
    )
54
54
""")
55
55
 
 
56
 
56
57
import bzrlib
57
58
from bzrlib import symbol_versioning
58
59
from bzrlib.symbol_versioning import (
1178
1179
        pending.extend(d for d in reversed(dirblock) if d[2] == _directory)
1179
1180
 
1180
1181
 
 
1182
_real_walkdirs_utf8 = None
 
1183
 
1181
1184
def _walkdirs_utf8(top, prefix=""):
1182
1185
    """Yield data about all the directories in a tree.
1183
1186
 
1192
1195
        path-from-top might be unicode or utf8, but it is the correct path to
1193
1196
        pass to os functions to affect the file in question. (such as os.lstat)
1194
1197
    """
1195
 
    fs_encoding = _fs_enc.upper()
1196
 
    if (sys.platform == 'win32' or
1197
 
        fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968')): # ascii
1198
 
        return _walkdirs_unicode_to_utf8(top, prefix=prefix)
1199
 
    else:
1200
 
        return _walkdirs_fs_utf8(top, prefix=prefix)
 
1198
    global _real_walkdirs_utf8
 
1199
    if _real_walkdirs_utf8 is None:
 
1200
        fs_encoding = _fs_enc.upper()
 
1201
        if win32utils.winver == 'Windows NT':
 
1202
            # Win98 doesn't have unicode apis like FindFirstFileW
 
1203
            # TODO: We possibly could support Win98 by falling back to the
 
1204
            #       original FindFirstFile, and using TCHAR instead of WCHAR,
 
1205
            #       but that gets a bit tricky, and requires custom compiling
 
1206
            #       for win98 anyway.
 
1207
            try:
 
1208
                from bzrlib._walkdirs_win32 import _walkdirs_utf8_win32_find_file
 
1209
            except ImportError:
 
1210
                _real_walkdirs_utf8 = _walkdirs_unicode_to_utf8
 
1211
            else:
 
1212
                _real_walkdirs_utf8 = _walkdirs_utf8_win32_find_file
 
1213
        elif fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'):
 
1214
            # ANSI_X3.4-1968 is a form of ASCII
 
1215
            _real_walkdirs_utf8 = _walkdirs_unicode_to_utf8
 
1216
        else:
 
1217
            _real_walkdirs_utf8 = _walkdirs_fs_utf8
 
1218
    return _real_walkdirs_utf8(top, prefix=prefix)
1201
1219
 
1202
1220
 
1203
1221
def _walkdirs_fs_utf8(top, prefix=""):