Patchwork D7692: windows: add a global equivalent to /etc/mercurial for *.rc processing

login
register
mail settings
Submitter phabricator
Date Dec. 23, 2019, 5:27 p.m.
Message ID <5d4565b0b0fb912d034cd3cc3fd3102b@localhost.localdomain>
Download mbox | patch
Permalink /patch/44023/
State Not Applicable
Headers show

Comments

phabricator - Dec. 23, 2019, 5:27 p.m.
Closed by commit rHG1ccf340acf14: windows: add a global equivalent to /etc/mercurial for *.rc processing (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7692?vs=18837&id=18910

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7692/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7692

AFFECTED FILES
  mercurial/helptext/config.txt
  mercurial/scmwindows.py
  relnotes/next

CHANGE DETAILS




To: mharbison72, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,5 +1,7 @@ 
 == New Features ==
 
+ * Windows will process hgrc files in %PROGRAMDATA%\Mercurial\hgrc.d.
+
 
 == New Experimental Features ==
 
diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py
--- a/mercurial/scmwindows.py
+++ b/mercurial/scmwindows.py
@@ -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
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -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::