[PATCH] hg: add standard Windows paths LOCALAPPDATA and APPDATA to config search path

Matt Harbison mharbison72 at gmail.com
Fri Mar 29 20:26:50 EDT 2019


On Wed, 27 Mar 2019 22:55:30 -0400, <james.may at draeger.com> wrote:

> # HG changeset patch
> # User James May <james.may at draeger.com>
> # Date 1553736615 -39600
> #      Thu Mar 28 12:30:15 2019 +1100
> # Node ID 06c0bf445f7fe0ab7d1d1a186e37a8ff38d893d5
> # Parent  eec20025ada33889233e553c5825aac36b708f6c
> hg: add standard Windows paths LOCALAPPDATA and APPDATA to config search  
> path

> diff -r eec20025ada3 -r 06c0bf445f7f mercurial/help/config.txt
> --- a/mercurial/help/config.txt Tue Mar 26 17:35:28 2019 +0100
> +++ b/mercurial/help/config.txt Thu Mar 28 12:30:15 2019 +1100
> @@ -67,12 +67,16 @@
>
>    On Windows, the following files are consulted:
>
> -  - ``<repo>/.hg/hgrc`` (per-repository)
> -  - ``%USERPROFILE%\.hgrc`` (per-user)
> -  - ``%USERPROFILE%\Mercurial.ini`` (per-user)
> -  - ``%HOME%\.hgrc`` (per-user)
> -  - ``%HOME%\Mercurial.ini`` (per-user)
> -  - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
> +  - ``<repo>\.hg\hgrc`` (per-repository)
> +  - ``%USERPROFILE%\mercurial.ini`` (per-user)
> +  - ``%USERPROFILE%\.hgrc`` (per-user) - note the leading ``.``
> +  - ``%LOCALAPPDATA%\hg\mercurial.ini`` (per-user and machine)
> +  - ``%LOCALAPPDATA%\hg\hgrc`` (per-user and machine)
> +  - ``%APPDATA%\hg\mercurial.ini`` (per-user)
> +  - ``%APPDATA%\hg\hgrc`` (per-user)
> +  - Either of the below specified in the registry key  
> ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation):
> +    - `mecurial.ini`
> +    - `*.rc`, if a directory
>    - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
>    - ``<install-dir>\Mercurial.ini`` (per-installation)
>    - ``<internal>/default.d/*.rc`` (defaults)
> diff -r eec20025ada3 -r 06c0bf445f7f mercurial/scmwindows.py
> --- a/mercurial/scmwindows.py   Tue Mar 26 17:35:28 2019 +0100
> +++ b/mercurial/scmwindows.py   Thu Mar 28 12:30:15 2019 +1100
> @@ -48,14 +48,13 @@
>
>  def userrcpath():
>      '''return os-specific hgrc search path to the user dir'''
> -    home = os.path.expanduser('~')
> -    path = [os.path.join(home, 'mercurial.ini'),
> -            os.path.join(home, '.hgrc')]
> -    userprofile = encoding.environ.get('USERPROFILE')
> -    if userprofile and userprofile != home:
> -        path.append(os.path.join(userprofile, 'mercurial.ini'))
> -        path.append(os.path.join(userprofile, '.hgrc'))
> -    return path
> +    paths = [os.path.join(encoding.environ.get('USERPROFILE'),         
> 'mercurial.ini'),
> +             os.path.join(encoding.environ.get('USERPROFILE'),         
> '.hgrc')
> +             os.path.join(encoding.environ.get('LOCALAPPDATA'), 'hg',  
> 'mercurial.ini'),
> +             os.path.join(encoding.environ.get('LOCALAPPDATA'), 'hg',  
> 'hgrc'),
> +             os.path.join(encoding.environ.get('APPDATA'),      'hg',  
> 'mercurial.ini'),
> +             os.path.join(encoding.environ.get('APPDATA'),      'hg',  
> 'hgrc')]
> +    return paths

It looks like %HOME% got lost in the shuffle here, and in the  
documentation.  It doesn't matter in cmd.exe, but it does do something  
under MSYS.  Can you restore that please?


More information about the Mercurial-devel mailing list