[PATCH] win32: Add rcpath registry value to installer

Steve Borho steve at borho.org
Wed Dec 5 23:14:39 CST 2007


On Tue, 2007-12-04 at 18:12 -0600, Steve Borho wrote:
> This concept could use more thought, as Lee pointed out on IRC.  Setting
> the registry key is like a nuclear option.  It prevents one from having
> multiple installs of Mercurial on a single Windows machine, at least it
> prevents each one from having it's own Mercurial.ini file.
> 
> Perhaps we should check for the existence of a Mercurial.ini in the same
> directory as the calling executable, and only consult the registry key
> if the file was not found?  I think that would satisfy all of our
> current installer requirements.

Completing this thought, does the attached patch look acceptable?  With
this version of system_rcpath_win32(), contrib/win32/mercurial.iss can
be left as it is now.  The minimalist installers will be able coexist on
the same machine as TortoiseHg or my NSI installer, without interfering
with each other.

-- 
Steve Borho (steve at borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F  E2E4 B0C2 5292 F2C6 2C8C
-------------- next part --------------
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1196917055 21600
# Node ID c02dd4d3612f7586b59cf579d1b30b7d1acd545f
# Parent  2e76e5a23c2baa858314115d443826d8c7ea11a9
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.

diff --git a/mercurial/util_win32.py b/mercurial/util_win32.py
--- a/mercurial/util_win32.py
+++ b/mercurial/util_win32.py
@@ -180,6 +180,17 @@ def testpid(pid):
 
 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 @@ def system_rcpath_win32():
                         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'''


More information about the Mercurial-devel mailing list