Mercurial > hg-stable
changeset 1583:32a4e6802864
make mercurial look in more places for config files.
now it searches <install dir>/etc/mercurial, /etc/mercurial, and user
hgrc.
this allows site-wide configuration to be shared over automounted nfs
partition, instead of chenging on every system. option of having local
configuration on every system remains.
old code for searching /etc/mercurial/hgrc.d never worked, this code
is tested and works.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 04 Nov 2005 11:51:01 -0800 |
parents | cd8fadd8c689 |
children | b3e94785ab69 |
files | doc/hgrc.5.txt mercurial/util.py |
diffstat | 2 files changed, 35 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/hgrc.5.txt Fri Nov 04 10:24:05 2005 -0800 +++ b/doc/hgrc.5.txt Fri Nov 04 11:51:01 2005 -0800 @@ -15,26 +15,38 @@ FILES ----- -Mercurial reads configuration data from up to three files, if they -exist. The names of these files depend on the system on which -Mercurial is installed. +Mercurial reads configuration data from several files, if they exist. +The names of these files depend on the system on which Mercurial is +installed. +(Unix) <install-root>/etc/mercurial/hgrc.d/*.rc:: +(Unix) <install-root>/etc/mercurial/hgrc:: + Per-installation configuration files, searched for in the + directory where Mercurial is installed. For example, if installed + in /shared/tools, Mercurial will look in + /shared/tools/etc/mercurial/hgrc. Options in these files apply to + all Mercurial commands executed by any user in any directory. + +(Unix) /etc/mercurial/hgrc.d/*.rc:: (Unix) /etc/mercurial/hgrc:: (Windows) C:\Mercurial\Mercurial.ini:: - Options in this global configuration file apply to all Mercurial - commands executed by any user in any directory. + Per-system configuration files, for the system on which Mercurial + is running. Options in these files apply to all Mercurial + commands executed by any user in any directory. Options in these + files override per-installation options. (Unix) $HOME/.hgrc:: (Windows) C:\Documents and Settings\USERNAME\Mercurial.ini - Per-user configuration options that apply to all Mercurial commands, - no matter from which directory they are run. Values in this file - override global settings. + Per-user configuration file, for the user running Mercurial. + Options in this file apply to all Mercurial commands executed by + any user in any directory. Options in this file override + per-installation and per-system options. (Unix, Windows) <repo>/.hg/hgrc:: Per-repository configuration options that only apply in a particular repository. This file is not version-controlled, and - will not get transferred during a "clone" operation. Values in - this file override global and per-user settings. + will not get transferred during a "clone" operation. Options in + this file override options in all other configuration files. SYNTAX ------
--- a/mercurial/util.py Fri Nov 04 10:24:05 2005 -0800 +++ b/mercurial/util.py Fri Nov 04 11:51:01 2005 -0800 @@ -13,7 +13,7 @@ import os, errno from i18n import gettext as _ from demandload import * -demandload(globals(), "re cStringIO shutil popen2 tempfile threading time") +demandload(globals(), "re cStringIO shutil popen2 sys tempfile threading time") def pipefilter(s, cmd): '''filter string S through command CMD, returning its output''' @@ -483,12 +483,18 @@ else: nulldev = '/dev/null' - hgrcd = '/etc/mercurial/hgrc.d' - hgrcs = [] - if os.path.isdir(hgrcd): - hgrcs = [f for f in os.listdir(hgrcd) if f.endswith(".rc")] - rcpath = map(os.path.normpath, hgrcs + - ['/etc/mercurial/hgrc', os.path.expanduser('~/.hgrc')]) + def rcfiles(path): + rcs = [os.path.join(path, 'hgrc')] + rcdir = os.path.join(path, 'hgrc.d') + try: + rcs.extend([os.path.join(rcdir, f) for f in os.listdir(rcdir) + if f.endswith(".rc")]) + except OSError, inst: pass + return rcs + rcpath = rcfiles(os.path.dirname(sys.argv[0]) + '/../etc/mercurial') + rcpath.extend(rcfiles('/etc/mercurial')) + rcpath.append(os.path.expanduser('~/.hgrc')) + rcpath = [os.path.normpath(f) for f in rcpath] def parse_patch_output(output_line): """parses the output produced by patch and returns the file name"""