For a couple of years, you've been able to expand shell variables inside .hg/hgrc
files.
So I just do something like this in my .bash_profile
:
export HGUSER=$(hostname)
Then inside .hg/hgrc
:
username=${HGUSER}
The BIG ADVANTAGE of this technique is that now you can put the EXACT SAME .hg/hgrc
on ALL the machines. The same is true of .bash_profile
: it can be the same on all machines. This helps a lot when you're automating machine configurations!
Note: the HGUSER
environment variable is an old way of telling Mercurial your username, so, technically, setting HGUSER
in .bash_profile
ought to solve the problem on its own, but I believe its use is deprecated/discouraged, and I recommend defining username
in .hg/hgrc
explicitly, as I've shown above.