diff options
Diffstat (limited to 'mercurial/windows.py')
-rw-r--r-- | mercurial/windows.py | 81 |
1 files changed, 19 insertions, 62 deletions
diff --git a/mercurial/windows.py b/mercurial/windows.py index aade404..ba3e6d8 100644 --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -6,26 +6,11 @@ # GNU General Public License version 2 or any later version. from i18n import _ -import osutil, encoding -import errno, msvcrt, os, re, sys, _winreg - -import win32 -executablepath = win32.executablepath -getuser = win32.getuser -hidewindow = win32.hidewindow -makedir = win32.makedir -nlinks = win32.nlinks -oslink = win32.oslink -samedevice = win32.samedevice -samefile = win32.samefile -setsignalhandler = win32.setsignalhandler -spawndetached = win32.spawndetached -termwidth = win32.termwidth -testpid = win32.testpid -unlink = win32.unlink +import osutil +import errno, msvcrt, os, re, sys nulldev = 'NUL:' -umask = 0022 +umask = 002 # wrap osutil.posixfile to provide friendlier exceptions def posixfile(name, mode='r', buffering=-1): @@ -105,9 +90,6 @@ def sshargs(sshcmd, host, user, port): def setflags(f, l, x): pass -def copymode(src, dst, mode=None): - pass - def checkexec(path): return False @@ -117,12 +99,11 @@ def checklink(path): def setbinary(fd): # When run without console, pipes may expose invalid # fileno(), usually set to -1. - fno = getattr(fd, 'fileno', None) - if fno is not None and fno() >= 0: - msvcrt.setmode(fno(), os.O_BINARY) + if hasattr(fd, 'fileno') and fd.fileno() >= 0: + msvcrt.setmode(fd.fileno(), os.O_BINARY) def pconvert(path): - return path.replace(os.sep, '/') + return '/'.join(path.split(os.sep)) def localpath(path): return path.replace('/', '\\') @@ -130,9 +111,6 @@ def localpath(path): def normpath(path): return pconvert(os.path.normpath(path)) -def normcase(path): - return encoding.upper(path) - def realpath(path): ''' Returns the true, canonical file system path equivalent to the given @@ -140,7 +118,7 @@ def realpath(path): ''' # TODO: There may be a more clever way to do this that also handles other, # less common file systems. - return os.path.normpath(normcase(os.path.realpath(path))) + return os.path.normpath(os.path.normcase(os.path.realpath(path))) def samestat(s1, s2): return False @@ -216,16 +194,17 @@ def findexe(command): def statfiles(files): '''Stat each file in files and yield stat or None if file does not exist. Cluster and cache stat per directory to minimize number of OS stat calls.''' + ncase = os.path.normcase dircache = {} # dirname -> filename -> status | None if file does not exist for nf in files: - nf = normcase(nf) + nf = ncase(nf) dir, base = os.path.split(nf) if not dir: dir = '.' cache = dircache.get(dir, None) if cache is None: try: - dmap = dict([(normcase(n), s) + dmap = dict([(ncase(n), s) for n, k, s in osutil.listdir(dir, True)]) except OSError, err: # handle directory not found in Python version prior to 2.5 @@ -291,39 +270,17 @@ def rename(src, dst): def gethgcmd(): return [sys.executable] + sys.argv[:1] +def termwidth(): + # cmd.exe does not handle CR like a unix console, the CR is + # counted in the line length. On 80 columns consoles, if 80 + # characters are written, the following CR won't apply on the + # current line but on the new one. Keep room for it. + return 79 + def groupmembers(name): # Don't support groups on Windows for now - raise KeyError + raise KeyError() -def isexec(f): - return False - -class cachestat(object): - def __init__(self, path): - pass - - def cacheable(self): - return False - -def lookupreg(key, valname=None, scope=None): - ''' Look up a key/value name in the Windows registry. - - valname: value name. If unspecified, the default value for the key - is used. - scope: optionally specify scope for registry lookup, this can be - a sequence of scopes to look up in order. Default (CURRENT_USER, - LOCAL_MACHINE). - ''' - if scope is None: - scope = (_winreg.HKEY_CURRENT_USER, _winreg.HKEY_LOCAL_MACHINE) - elif not isinstance(scope, (list, tuple)): - scope = (scope,) - for s in scope: - try: - val = _winreg.QueryValueEx(_winreg.OpenKey(s, key), valname)[0] - # never let a Unicode string escape into the wild - return encoding.tolocal(val.encode('UTF-8')) - except EnvironmentError: - pass +from win32 import * expandglobs = True |