win32: favor local mercurial.ini over registry key
authorSteve Borho <steve@borho.org>
Wed, 05 Dec 2007 22:57:35 -0600
changeset 5619 55d3e845736a
parent 5618 6e1a61b14bbf
child 5620 652f57de3ccf
child 5622 ea2625655baf
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.
mercurial/util_win32.py
--- 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'''