Take the 2-minute tour ×

Is there any way for me to refer to an external configuration in Mercurial? Our repository is on a shared drive so at the moment the last user to use it is the username it keeps since by default hgrc is under the .hg folder local to the repository.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You could place one in the root of your home directory.

According to the man page, the following locations are checked for per-user configuration files.

   (Unix) $HOME/.hgrc
   (Windows) %USERPROFILE%\.hgrc
   (Windows) %USERPROFILE%\Mercurial.ini
   (Windows) %HOME%\.hgrc
   (Windows) %HOME%\Mercurial.ini

In your per user .hgrc you can have a section like this:

username =Your Name<example@example.com>

When you commit and push, the push destinations in .hg/hgrc will be used and your username from the per user file will be used for the commit.

Also, you should consider sharing your repository in a way other then a shared drive. hg lets you pull and push from each computer with a repository and if you need the notion of a 'central repo' you could put it behind hgweb.cgi and push via https or ssh

share|improve this answer
add comment

I agree completely with Daniel — each user should configure the username in his personal config file. The .hg/hgrc file should not contain a username.

However, let me answer your question about include files: you can include one configuration file in another with:

%include some/file

See the hgrc(5) man page.

share|improve this answer
add comment

Your Answer


