mercurial on macos doesn't read ~/.config/hg/hgrc

75 views Asked by At

I installed mercurial on my Mabook-Air (M1) using:

brew install mercurial

Mercurial (6.1.2) is working fine, but the configurations files that I copied over from my Linux setup (everything under ~/.config/hg/ including hgrc and a global hgignore) cannot be found.

man hgrc indicates that ${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc is consulted under Unix. Is macOS not considered Unix?

1

There are 1 answers

0
Anthon On

Running hg config --debug | fgrep 'read config' on (Arch) Linux gives:

read config from: resource:mercurial.defaultrc.mergetools.rc
read config from: /usr/local/etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc
read config from: /home/anthon/.hgrc
read config from: /home/anthon/.config/hg/hgrc

whereas on macOS it gives:

read config from: resource:mercurial.defaultrc.mergetools.rc
read config from: /opt/homebrew/etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc
read config from: /Users/anthon/.hgrc

If you don't want to clobber your home directory with another hidden file ~/.hgrc, you can do:

sudo mkdir /etc/mercurial   # wasn't there on my system
echo '%include ~/.config/hg/hgrc' | sudo tee -a /etc/mercurial/hgrc

After which your ~/.config/hg/hgrc should be read on mercurial startup.

Unfortunately using hg config --edit not only tries to edit ~/.hgrc, but it also creates it even if you quit your editor without making changes. After that your username will be unset (as ~/.hgrc is read after /etc/mercurial/hgrc