sapling/tests/test-xdg.t
Stefan Filip 3f33e9f3e9 configparser: fix XDG config loading
Summary:
The spec for both XDG and Mercurial say that when the XDG_CONFIG_HOME variable
is not set, we should default to $HOME/.config.

Windows and macOS also have a designated config folder outside of the home directory.
The `dirs` crate provides consistent access to this folder. I see no harm in looking at config
 folders across all operating systems.

Reviewed By: quark-zju

Differential Revision: D14380686

fbshipit-source-id: 5e5a9cd4694aaa49fbc526f4917dc4afdaeb9842
2019-03-11 15:32:55 -07:00

21 lines
496 B
Perl

#if no-windows no-osx
$ mkdir -p xdgconf/hg
$ echo '[ui]' > xdgconf/hg/hgrc
$ echo 'username = foobar' >> xdgconf/hg/hgrc
$ XDG_CONFIG_HOME="`pwd`/xdgconf" ; export XDG_CONFIG_HOME
$ unset HGRCPATH
$ hg config ui.username 2>/dev/null
foobar
$ mkdir -p home/.config/hg
$ echo '[ui]' > home/.config/hg/hgrc
$ echo 'username = bazbaz' >> home/.config/hg/hgrc
$ HOME="`pwd`/home" ; export HOME
$ unset XDG_CONFIG_HOME
$ hg config ui.username 2>/dev/null
bazbaz
#endif