Issue #2379 open

# settings: mercurial.ini search path

fchrist
created an issue

In mercurial doc (http://www.selenic.com/mercurial/hgrc.5.html), I can read that configuration search path order is the following for windows:

```<repo>/.hg/hgrc
(Windows) %USERPROFILE%\.hgrc
**(Windows) %USERPROFILE%\Mercurial.ini**
(Windows) %HOME%\.hgrc
(Windows) %HOME%\Mercurial.ini
(Windows) <install-dir>\Mercurial.ini or
(Windows) <install-dir>\hgrc.d\*.rc or
(Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial
```

With tortoiseHG, when HOME is set, and I open settings, the file that is proposed for global settings is %HOME%/.hgrc, even if I also have a %USERPROFILE%\Mercurial.ini.

• edited description

Mercurial loads settings from `scmutil.rcpath()` in order, with overriding existing. So, maybe SettingsDialog should search rc file in reverse order.

I might be easier to consider the the docs are wrong. The code clearly puts %HOME% first: https://selenic.com/repo/hg/file/default/mercurial/scmwindows.py#l39

TortoiseHG uses whatever scmutil.userrcpath returns: https://bitbucket.org/tortoisehg/thg/src/5b20d939f72bfd09ec4f8f2fd648c857c5270d7b/tortoisehg/hgqt/settings.py?at=default&fileviewer=file-view-default#settings.py-1205

If you assume the ordering in the hg code is correct, then thg seems to work properly.

A related (though perhaps separate?) issue is that the value of HGRCPATH is ignored.

I meant because `HOME` is loaded prior to `USERPROFILE`, `USERPROFILE` is stronger than `HOME`.

the value of HGRCPATH is ignored.

If `HGRCPATH` is specified, there is no distinction between system/user search paths.