Mercurial > hg > mercurial-source
diff mercurial/scmposix.py @ 31720:354020079723
hg: allow usage of XDG_CONFIG_HOME/hg/hgrc
Modern applications must use the following paths to store configuration files:
- $XDG_CONFIG_HOME/hg/hgrc,
- $HOME/.config/hg/hgrc (if XDG_CONFIG_HOME is unset or not absolute).
For backward compatibility, ~/.hgrc is still created if no hgrc exist using hg
config --edit.
See https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
author | David Demelier <demelier.david@gmail.com> |
---|---|
date | Tue, 07 Feb 2017 17:33:35 +0100 (2017-02-07) |
parents | 16b5df5792a8 |
children | 7c09b071318a |
line wrap: on
line diff
--- a/mercurial/scmposix.py +++ b/mercurial/scmposix.py @@ -40,8 +40,15 @@ def userrcpath(): if pycompat.sysplatform == 'plan9': return [encoding.environ['home'] + '/lib/hgrc'] + elif pycompat.sysplatform == 'darwin': + return [os.path.expanduser('~/.hgrc')] else: - return [os.path.expanduser('~/.hgrc')] + confighome = encoding.environ.get('XDG_CONFIG_HOME') + if confighome is None or not os.path.isabs(confighome): + confighome = os.path.expanduser('~/.config') + + return [os.path.expanduser('~/.hgrc'), + os.path.join(confighome, 'hg', 'hgrc')] def termsize(ui): try: