~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-17 15:14:58 UTC
  • mto: This revision was merged to the branch mainline in revision 3560.
  • Revision ID: john@arbash-meinel.com-20080717151458-1qou6e4hkyr309f7
Change the logic for selecting a real _walkdirs_utf8 implementation,
and put it under test, so that we know it is actively being used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1179
1179
        pending.extend(d for d in reversed(dirblock) if d[2] == _directory)
1180
1180
 
1181
1181
 
 
1182
_real_walkdirs_utf8 = None
 
1183
 
1182
1184
def _walkdirs_utf8(top, prefix=""):
1183
1185
    """Yield data about all the directories in a tree.
1184
1186
 
1193
1195
        path-from-top might be unicode or utf8, but it is the correct path to
1194
1196
        pass to os functions to affect the file in question. (such as os.lstat)
1195
1197
    """
1196
 
    fs_encoding = _fs_enc.upper()
1197
 
    if sys.platform == 'win32':
1198
 
        try:
1199
 
            from bzrlib._walkdirs_win32 import _walkdirs_utf8_win32_find_file
1200
 
        except ImportError:
1201
 
            return _walkdirs_unicode_to_utf8(top, prefix=prefix)
 
1198
    global _real_walkdirs_utf8
 
1199
    if _real_walkdirs_utf8 is None:
 
1200
        fs_encoding = _fs_enc.upper()
 
1201
        if sys.platform == 'win32':
 
1202
            try:
 
1203
                from bzrlib._walkdirs_win32 import _walkdirs_utf8_win32_find_file
 
1204
            except ImportError:
 
1205
                _real_walkdirs_utf8 = _walkdirs_unicode_to_utf8
 
1206
            else:
 
1207
                _real_walkdirs_utf8 = _walkdirs_utf8_win32_find_file
 
1208
        elif fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'):
 
1209
            # ANSI_X3.4-1968 is a form of ASCII
 
1210
            _real_walkdirs_utf8 = _walkdirs_unicode_to_utf8
1202
1211
        else:
1203
 
            return _walkdirs_utf8_win32_find_file(top, prefix=prefix)
1204
 
    if fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'): # ascii
1205
 
        return _walkdirs_unicode_to_utf8(top, prefix=prefix)
1206
 
    else:
1207
 
        return _walkdirs_fs_utf8(top, prefix=prefix)
 
1212
            _real_walkdirs_utf8 = _walkdirs_fs_utf8
 
1213
    return _real_walkdirs_utf8(top, prefix=prefix)
1208
1214
 
1209
1215
 
1210
1216
def _walkdirs_fs_utf8(top, prefix=""):