[PATCH] win32: read system rcpath from registry

Steve Borho steve at borho.org
Sun Dec 2 09:28:35 CST 2007


On Sun, 2007-12-02 at 16:15 +0100, Patrick Mézard wrote:
> 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 ;-))

You mean the _ in front of _rcpath?  I thought I was obeying some
convention :-)

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

Sure, the NSI installer uses them.  It's currently resorting to setting
HGRCPATH, but that is a real annoyance because it has to be set
individually for every user, otherwise they will have no user config
file.  HGRCPATH also causes grief if the user tries to use another
Mercurial installer.

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

Same patch or new patch?

> Otherwise, the patch looks good to me.

ok

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



More information about the Mercurial-devel mailing list