comparison mercurial/windows.py @ 8421:b6d0fa8c7685

posixfile: remove posixfile_nt and fix import bug in windows.py The posixfile_nt class has been superseded by posixfile in osutils.c, which works on Windows NT and above. All other systems get the regular python file class which is assigned to posixfile in posix.py (for POSIX) and in the pure python version of osutils.py (for Win 9x or Windows NT in pure mode).
author Sune Foldager <cryo@cyanite.org>
date Wed, 13 May 2009 21:36:16 +0200
parents fa901423ac23
children 4429751f5da7
comparison
equal deleted inserted replaced
8420:f53bc3e37655 8421:b6d0fa8c7685
6 # GNU General Public License version 2, incorporated herein by reference. 6 # GNU General Public License version 2, incorporated herein by reference.
7 7
8 from i18n import _ 8 from i18n import _
9 import osutil, error 9 import osutil, error
10 import errno, msvcrt, os, re, sys 10 import errno, msvcrt, os, re, sys
11
11 nulldev = 'NUL:' 12 nulldev = 'NUL:'
12
13 umask = 002 13 umask = 002
14
15 # wrap osutil.posixfile to provide friendlier exceptions
16 def posixfile(name, mode='r', buffering=-1):
17 try:
18 return osutil.posixfile(name, mode, buffering)
19 except WindowsError, err:
20 raise WinIOError(err)
21 posixfile.__doc__ = osutil.posixfile.__doc__
14 22
15 class winstdout: 23 class winstdout:
16 '''stdout on windows misbehaves if sent through a pipe''' 24 '''stdout on windows misbehaves if sent through a pipe'''
17 25
18 def __init__(self, fp): 26 def __init__(self, fp):
268 pass 276 pass
269 277
270 try: 278 try:
271 # override functions with win32 versions if possible 279 # override functions with win32 versions if possible
272 from win32 import * 280 from win32 import *
273 if not _is_win_9x():
274 posixfile = posixfile_nt
275 try:
276 # fast, buffered POSIX-like file support
277 from osutil import posixfile as _posixfile
278 def posixfile(name, mode='r', buffering=-1):
279 # wrap osutil.posixfile to provide friendlier exceptions
280 try:
281 return _posixfile(name, mode, buffering)
282 except WindowsError, err:
283 raise WinIOError(err)
284 posixfile.__doc__ = _posixfile.__doc__
285 except ImportError:
286 # slow, unbuffered POSIX-like file support
287 posixfile = posixfile_nt
288 except ImportError: 281 except ImportError:
289 posixfile = file 282 pass