changeset 5619:55d3e845736a

win32: favor local mercurial.ini over registry key Hopefully this is the best of both worlds. Multiple py2exe based installers can coexist on one machine, while source and lib based Mercurial users can still use a registry key in lieu of resorting to HGRCPATH.
author Steve Borho <steve@borho.org>
date Wed, 05 Dec 2007 22:57:35 -0600
parents 6e1a61b14bbf
children 652f57de3ccf ea2625655baf
files mercurial/util_win32.py
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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'''