mercurial/util_win32.py
changeset 5619 55d3e845736a
parent 5612 7c976bb039af
child 5840 c67dfc4ecba6
child 5847 e52383c7e7ab
--- a/mercurial/util_win32.py	Thu Dec 06 13:11:36 2007 -0800
+++ b/mercurial/util_win32.py	Wed Dec 05 22:57:35 2007 -0600
@@ -180,6 +180,17 @@
 
 def system_rcpath_win32():
     '''return default os-specific hgrc search path'''
+    proc = win32api.GetCurrentProcess()
+    try:
+        # This will fail on windows < NT
+        filename = win32process.GetModuleFileNameEx(proc, 0)
+    except:
+        filename = win32api.GetModuleFileName(0)
+    # Use mercurial.ini found in directory with hg.exe
+    progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini')
+    if os.path.isfile(progrc):
+        return [progrc]
+    # else look for a system rcpath in the registry
     try:
         value = win32api.RegQueryValue(
                 win32con.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Mercurial')
@@ -193,14 +204,7 @@
                         rcpath.append(os.path.join(p, f))
         return rcpath
     except pywintypes.error:
-        pass
-    proc = win32api.GetCurrentProcess()
-    try:
-        # This will fail on windows < NT
-        filename = win32process.GetModuleFileNameEx(proc, 0)
-    except:
-        filename = win32api.GetModuleFileName(0)
-    return [os.path.join(os.path.dirname(filename), 'mercurial.ini')]
+        return []
 
 def user_rcpath_win32():
     '''return os-specific hgrc search path to the user dir'''