mercurial/util_win32.py
changeset 5583 1b5b81d9039b
parent 4998 81f8ff2a9bf2
child 5612 7c976bb039af
--- a/mercurial/util_win32.py	Sun Dec 02 14:06:10 2007 +0100
+++ b/mercurial/util_win32.py	Sun Dec 02 17:15:03 2007 +0100
@@ -16,6 +16,7 @@
 from i18n import _
 import errno, os, pywintypes, win32con, win32file, win32process
 import cStringIO, winerror
+import osutil
 from win32com.shell import shell,shellcon
 
 class WinError:
@@ -179,6 +180,20 @@
 
 def system_rcpath_win32():
     '''return default os-specific hgrc search path'''
+    try:
+        value = win32api.RegQueryValue(
+                win32con.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Mercurial')
+        rcpath = []
+        for p in value.split(os.pathsep):
+            if p.lower().endswith('mercurial.ini'):
+                rcpath.append(p)
+            elif os.path.isdir(p):
+                for f, kind in osutil.listdir(p):
+                    if f.endswith('.rc'):
+                        rcpath.append(os.path.join(p, f))
+        return rcpath
+    except pywintypes.error:
+        pass
     proc = win32api.GetCurrentProcess()
     try:
         # This will fail on windows < NT