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

james.may at draeger.com james.may at draeger.com
Wed Mar 27 22:55:30 EDT 2019


# 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

In the spirit of changeset 354020079723 this adds:
  - %LOCALAPPDATA%\hg\{mecurial.ini, hgrc} and
  - %APPDATA%\hg\{mecurial.ini, hgrc}
to the existing location:
  - %USERPROFILE%\{mecurial.ini, .hgrc}
read for configuration.

%USERPROFILE% is used directly rather than using expanduser('~'), as they are
the same on every version Windows from this century.

For backward compatibility, %USERPROFILE%\mercurial.ini is still first and will
be created by hg config --edit on Windows.

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

 def termsize(ui):
     return win32.termsize()
---
This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.

Diese Nachricht enthaelt vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfaenger dieser E-mail sein, senden Sie bitte diese an den Absender zurueck und loeschen Sie die E-mail aus Ihrem System.


More information about the Mercurial-devel mailing list