/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

Merge in the BranchBuilder updates, which brings in a newer bzr.dev

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 (
641
642
    offset = datetime.fromtimestamp(t) - datetime.utcfromtimestamp(t)
642
643
    return offset.days * 86400 + offset.seconds
643
644
 
 
645
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
644
646
    
645
647
def format_date(t, offset=0, timezone='original', date_fmt=None,
646
648
                show_offset=True):
672
674
        offset_str = ' %+03d%02d' % (offset / 3600, (offset / 60) % 60)
673
675
    else:
674
676
        offset_str = ''
 
677
    # day of week depends on locale, so we do this ourself
 
678
    date_fmt = date_fmt.replace('%a', weekdays[tt[6]])
675
679
    return (time.strftime(date_fmt, tt) +  offset_str)
676
680
 
677
681
 
1175
1179
        pending.extend(d for d in reversed(dirblock) if d[2] == _directory)
1176
1180
 
1177
1181
 
 
1182
_real_walkdirs_utf8 = None
 
1183
 
1178
1184
def _walkdirs_utf8(top, prefix=""):
1179
1185
    """Yield data about all the directories in a tree.
1180
1186
 
1189
1195
        path-from-top might be unicode or utf8, but it is the correct path to
1190
1196
        pass to os functions to affect the file in question. (such as os.lstat)
1191
1197
    """
1192
 
    fs_encoding = _fs_enc.upper()
1193
 
    if (sys.platform == 'win32' or
1194
 
        fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968')): # ascii
1195
 
        return _walkdirs_unicode_to_utf8(top, prefix=prefix)
1196
 
    else:
1197
 
        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)
1198
1219
 
1199
1220
 
1200
1221
def _walkdirs_fs_utf8(top, prefix=""):