The Mercurial system uses a set of configuration files to control aspects of its behavior.
The configuration files use a simple ini-file format. A configuration file consists of sections, led by a [section] header and followed by name = value entries:
[ui]
Username = Firstname Lastname
Verbose = True
The above entries will be referred to as ui. username and ui. verbose, respectively. See the Syntax section below.
Files
Mercurial reads configuration data from several files, if they exist. These files do not exist by default and you will have to create the appropriate configuration files yourself: global configuration like the username setting is typically put into %USERPROFILE%mercurial. ini or $HOME/.hgrc and local configuration is put into the per-repository /.hg/hgrc file.
The names of these files depend on the system on which Mercurial is installed. *.rc files from a single directory are read in alphabetical order, later ones overriding earlier ones. Where multiple paths are given below, settings from earlier paths override later ones.
(Unix, Windows) /.hg/hgrc
Per-repository configuration options that only apply in a particular repository. This file is not version-controlled, and will not get transferred during a “clone” operation. Options in this file override options in all other configuration files. On Unix, most of this file will be ignored if it doesn’t belong to a trusted user or to a trusted group. See the documentation for the [trusted] section below for more details.
(Unix) $HOME/.hgrc
(Windows) %USERPROFILE%.hgrc
(Windows) %USERPROFILE%Mercurial. ini
(Windows) %HOME%.hgrc
(Windows) %HOME%Mercurial. ini
Per-user configuration file(s), for the user running Mercurial. On Windows 9x, %HOME% is replaced by %APPDATA%. Options in these files apply to all Mercurial commands executed by this user in any directory. Options in these files override
per-system and per-installation options.
(Unix) /etc/mercurial/hgrc
(Unix) /etc/mercurial/hgrc. d/*.rc
Per-system configuration files, for the system on which Mercurial is running. Options in these files apply to all Mercurial commands executed by any user in any directory. Options in these files override per-installation options.
(Unix) /etc/mercurial/hgrc
(Unix) /etc/mercurial/hgrc. d/*.rc
Per-installation configuration files, searched for in the directory where Mercurial is installed. is the parent directory of the hg executable (or symlink) being run. For example, if installed in /shared/tools/bin/hg, Mercurial will look in /shared/tools/etc/mercurial/hgrc. Options in these files apply to all Mercurial commands executed by any user in any directory.
(Windows) Mercurial. ini or
(Windows) hgrc. d*.rc or
(Windows) HKEY_LOCAL_MACHINESOFTWAREMercurial
Per-installation/system configuration files, for the system on which Mercurial is running. Options in these files apply to all Mercurial commands executed by any user in any directory. Registry keys contain PATH-like strings, every part of which must reference a Mercurial. ini file or be a directory where *.rc files will be read. Mercurial checks each of these locations in the specified order until one or more configuration files are detected. If the pywin32 extensions are not installed, Mercurial will only look for site-wide configuration in C:MercurialMercurial. ini.
Syntax
A configuration file consists of sections, led by a [section] header and followed by name = value entries (sometimes called configuration keys):
[spam]
Eggs=ham
Green=
eggs
Each line contains one entry.