From patchwork Sun Nov 2 16:05:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] config: introduce "built-in" default configuration settings in default.d From: Mads Kiilerich X-Patchwork-Id: 6531 Message-Id: <5ae61db1890019841e91.1414944359@localhost.localdomain> To: mercurial-devel@selenic.com Date: Sun, 02 Nov 2014 17:05:59 +0100 # HG changeset patch # User Mads Kiilerich # Date 1409859395 -7200 # Thu Sep 04 21:36:35 2014 +0200 # Branch stable # Node ID 5ae61db1890019841e9178c5b7fb56a9aba1af1e # Parent cc1cbb0bba8ed1d95c8f1b8e27d4d2893e0dcca7 config: introduce "built-in" default configuration settings in default.d This helps providing a more consistent user experience on all platforms and with all packaging. The exact location of default.d depends on how Mercurial is installed and whether it is 'frozen'. The exact location should never be relevant to users and is intentionally not explained in details in the documentation. It will however always be next to the help and templates files. Note that setting HGRCPATH also disables these defaults. I don't know if that should be considered a bug or a feature. diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -38,6 +38,7 @@ ones. - ``/etc/mercurial/hgrc.d/*.rc`` (per-installation) - ``/etc/mercurial/hgrc`` (per-system) - ``/etc/mercurial/hgrc.d/*.rc`` (per-system) + - ``/default.d/*.rc`` (defaults) .. container:: verbose.windows @@ -51,6 +52,7 @@ ones. - ``\Mercurial.ini`` (per-installation) - ``\hgrc.d\*.rc`` (per-installation) - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation) + - ``/default.d/*.rc`` (defaults) .. note:: @@ -67,6 +69,7 @@ ones. - ``/lib/mercurial/hgrc.d/*.rc`` (per-installation) - ``/lib/mercurial/hgrc`` (per-system) - ``/lib/mercurial/hgrc.d/*.rc`` (per-system) + - ``/default.d/*.rc`` (defaults) Per-repository configuration options only apply in a particular repository. This file is not version-controlled, and @@ -102,6 +105,13 @@ is running. Options in these files apply executed by any user in any directory. Options in these files override per-installation options. +Mercurial comes with some default configuration. The default configuration +files are installed with Mercurial and will be overwritten on upgrades. Default +configuration files should never be edited by users or administrators but can +be overridden in other configuration files. So far the directory only contains +merge tool configuration but packagers can also put other default configuration +there. + Syntax ====== diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -495,7 +495,13 @@ def walkrepos(path, followsym=False, see def osrcpath(): '''return default os-specific hgrc search path''' - path = systemrcpath() + path = [] + defaultpath = os.path.join(util.datapath, 'default.d') + if os.path.isdir(defaultpath): + for f, kind in osutil.listdir(defaultpath): + if f.endswith('.rc'): + path.append(os.path.join(defaultpath, f)) + path.extend(systemrcpath()) path.extend(userrcpath()) path = [os.path.normpath(f) for f in path] return path diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -517,6 +517,7 @@ cygwinccompiler.Mingw32CCompiler = Hacke packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', 'help/*.txt', + 'default.d/*.rc', 'dummycert.pem']} def ordinarypath(p):