[PATCH] win32: read system rcpath from registry

Patrick Mézard pmezard at gmail.com
Sun Dec 2 09:15:14 CST 2007


Steve Borho a écrit :
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1196569615 21600
> # Node ID 415a66f248d90b9bcb4e242f8728efa1c06c3ee3
> # Parent  feac5b0bf9bad2c125ebd5f3e133bcd46ecb8c7c
> 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 --git a/mercurial/util_win32.py b/mercurial/util_win32.py
> --- a/mercurial/util_win32.py
> +++ b/mercurial/util_win32.py
> @@ -16,6 +16,7 @@ from i18n import _
>  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 testpid(pid):
>  
>  def system_rcpath_win32():
>      '''return default os-specific hgrc search path'''
> +    try:
> +        value = win32api.RegQueryValue(
> +                win32con.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Mercurial')
> +        _rcpath = []

This prefix should be removed (copy/paste are bad ;-))

> +        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

Do you have a use case for the .rc directories ? Under Windows, they are only looked for when parsing HGRCPATH. Did you add them for consistency or ?

Could you update "doc/hgrc.5.txt" as well ?

Otherwise, the patch looks good to me.




More information about the Mercurial-devel mailing list