mercurial/util_win32.py
changeset 5583 1b5b81d9039b
parent 4998 81f8ff2a9bf2
child 5612 7c976bb039af
equal deleted inserted replaced
5582:60d46e0bd656 5583:1b5b81d9039b
    14 import win32api
    14 import win32api
    15 
    15 
    16 from i18n import _
    16 from i18n import _
    17 import errno, os, pywintypes, win32con, win32file, win32process
    17 import errno, os, pywintypes, win32con, win32file, win32process
    18 import cStringIO, winerror
    18 import cStringIO, winerror
       
    19 import osutil
    19 from win32com.shell import shell,shellcon
    20 from win32com.shell import shell,shellcon
    20 
    21 
    21 class WinError:
    22 class WinError:
    22     winerror_map = {
    23     winerror_map = {
    23         winerror.ERROR_ACCESS_DENIED: errno.EACCES,
    24         winerror.ERROR_ACCESS_DENIED: errno.EACCES,
   177         return details[0] != winerror.ERROR_INVALID_PARAMETER
   178         return details[0] != winerror.ERROR_INVALID_PARAMETER
   178     return True
   179     return True
   179 
   180 
   180 def system_rcpath_win32():
   181 def system_rcpath_win32():
   181     '''return default os-specific hgrc search path'''
   182     '''return default os-specific hgrc search path'''
       
   183     try:
       
   184         value = win32api.RegQueryValue(
       
   185                 win32con.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Mercurial')
       
   186         rcpath = []
       
   187         for p in value.split(os.pathsep):
       
   188             if p.lower().endswith('mercurial.ini'):
       
   189                 rcpath.append(p)
       
   190             elif os.path.isdir(p):
       
   191                 for f, kind in osutil.listdir(p):
       
   192                     if f.endswith('.rc'):
       
   193                         rcpath.append(os.path.join(p, f))
       
   194         return rcpath
       
   195     except pywintypes.error:
       
   196         pass
   182     proc = win32api.GetCurrentProcess()
   197     proc = win32api.GetCurrentProcess()
   183     try:
   198     try:
   184         # This will fail on windows < NT
   199         # This will fail on windows < NT
   185         filename = win32process.GetModuleFileNameEx(proc, 0)
   200         filename = win32process.GetModuleFileNameEx(proc, 0)
   186     except:
   201     except: