# HG changeset patch # User Steve Borho # Date 1196612103 -3600 # Node ID 1b5b81d9039b79e0ca2733e2e3cb442778700a91 # Parent 60d46e0bd6569baba11546c09cae1a65d8870320 win32: read system rcpath from registry Using the module name was not always helpful. It breaks down when Mercurial is installed as source and when the Mercurial libs are used by external applications. This patch allows Mercurial installers to store the system wide rcpath in the registry, where it can always be found. HGRCPATH is a poor option for storing the system wide rcpath, since it overrides both the system and user rcpaths. diff -r 60d46e0bd656 -r 1b5b81d9039b doc/hgrc.5.txt --- a/doc/hgrc.5.txt Sun Dec 02 14:06:10 2007 +0100 +++ b/doc/hgrc.5.txt Sun Dec 02 17:15:03 2007 +0100 @@ -17,7 +17,9 @@ Mercurial reads configuration data from several files, if they exist. The names of these files depend on the system on which Mercurial is -installed. +installed. Windows registry keys contain PATH-like strings, every +part must reference a Mercurial.ini file or be a directory where *.rc +files will be read. (Unix) /etc/mercurial/hgrc.d/*.rc:: (Unix) /etc/mercurial/hgrc:: @@ -29,6 +31,8 @@ (Unix) /etc/mercurial/hgrc.d/*.rc:: (Unix) /etc/mercurial/hgrc:: +(Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial:: + or:: (Windows) C:\Mercurial\Mercurial.ini:: Per-system configuration files, for the system on which Mercurial is running. Options in these files apply to all Mercurial diff -r 60d46e0bd656 -r 1b5b81d9039b mercurial/util_win32.py --- 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