windows: add a global equivalent to /etc/mercurial for *.rc processing
This follows the Unix model of processing this directory immediately after
<internal>/*.rc, and prior to the installation relative files. Since the Unix
processing supports both a directory and a file (the former overriding the
latter), and since %HOME% supports both `*.ini` and `.hgrc` (again, the former
overriding the latter), this does too. The Unix file doesn't have a `.` prefix,
so it's not used here either.
Note that this is the opposite order of processing the exe relative paths. But
since it's in agreement with Unix, %HOME% and %USERPROFILE%, it seems reasonable
to ignore that. Maybe we can change that and take a BC, because that's
something the installer should be controlling, and I can't imagine people having
both paths *and* conflicting settings.
Differential Revision: https://phab.mercurial-scm.org/D7692
--- a/mercurial/helptext/config.txt Fri Dec 13 10:31:00 2019 -0800
+++ b/mercurial/helptext/config.txt Tue Dec 17 22:08:07 2019 -0500
@@ -75,6 +75,9 @@
- ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
- ``<install-dir>\hgrc.d\*.rc`` (per-installation)
- ``<install-dir>\Mercurial.ini`` (per-installation)
+ - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
+ - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
+ - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
- ``<internal>/*.rc`` (defaults)
.. note::
--- a/mercurial/scmwindows.py Fri Dec 13 10:31:00 2019 -0800
+++ b/mercurial/scmwindows.py Tue Dec 17 22:08:07 2019 -0500
@@ -38,6 +38,20 @@
# Use hgrc.d found in directory with hg.exe
_processdir(os.path.join(os.path.dirname(filename), b'hgrc.d'))
+ # treat a PROGRAMDATA directory as equivalent to /etc/mercurial
+ programdata = encoding.environ.get(b'PROGRAMDATA')
+ if programdata:
+ programdata = os.path.join(programdata, b'Mercurial')
+ _processdir(os.path.join(programdata, b'hgrc.d'))
+
+ ini = os.path.join(programdata, b'mercurial.ini')
+ if os.path.isfile(ini):
+ rcpath.append(ini)
+
+ ini = os.path.join(programdata, b'hgrc')
+ if os.path.isfile(ini):
+ rcpath.append(ini)
+
# next look for a system rcpath in the registry
value = util.lookupreg(
b'SOFTWARE\\Mercurial', None, winreg.HKEY_LOCAL_MACHINE
--- a/relnotes/next Fri Dec 13 10:31:00 2019 -0800
+++ b/relnotes/next Tue Dec 17 22:08:07 2019 -0500
@@ -1,5 +1,7 @@
== New Features ==
+ * Windows will process hgrc files in %PROGRAMDATA%\Mercurial\hgrc.d.
+
== New Experimental Features ==