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. If the lines that follow are
indented, they are treated as continuations of that entry.
Leading whitespace is removed from values. Empty lines are
skipped. Lines beginning with #
or ;
are ignored and may be used
to provide comments.
Configuration keys can be set multiple times, in which case
Mercurial will use the value that was configured last. As an
example:
[spam]
eggs=large
ham=serrano
eggs=small
This would set the configuration key named eggs
to small
.
It is also possible to define a section multiple times. A section
can be redefined on the same and/or on different configuration
files. For example:
[foo]
eggs=large
ham=serrano
eggs=small
[bar]
eggs=ham
green=
eggs
[foo]
ham=prosciutto
eggs=medium
bread=toasted
This would set the eggs
, ham
, and bread
configuration keys of the
foo
section to medium
, prosciutto
, and toasted
, respectively. As
you can see there only thing that matters is the last value that
was set for each of the configuration keys.
If a configuration key is set multiple times in different
configuration files the final value will depend on the order in
which the different configuration files are read, with settings
from earlier paths overriding later ones as described on the
Files
section above.
A line of the form %include file
will include file
into the
current configuration file. The inclusion is recursive, which
means that included files can include other files. Filenames are
relative to the configuration file in which the %include
directive is found. Environment variables and ~user
constructs
are expanded in file
. This lets you do something like:
%include ~/.hgrc.d/$HOST.rc
to include a different configuration file on each computer you
use.
A line with %unset name
will remove name
from the current
section, if it has been set previously.
The values are either free-form text strings, lists of text
strings, or Boolean values. Boolean values can be set to true
using any of "1", "yes", "true", or "on" and to false using "0",
"no", "false", or "off" (all case insensitive).
List values are separated by whitespace or comma, except when
values are placed in double quotation marks:
allow_read = "John Doe, PhD", brian, betty
Quotation marks can be escaped by prefixing them with a
backslash. Only quotation marks at the beginning of a word is
counted as a quotation (e.g., foo"bar baz
is the list of foo"bar
and baz
).