config.txt 104 KB
Newer Older
1 2
The Mercurial system uses a set of configuration files to control
aspects of its behavior.
3

4 5 6 7 8 9 10 11 12 13
Troubleshooting
===============

If you're having problems with your configuration,
:hg:`config --debug` can help you understand what is introducing
a setting into your environment.

See :hg:`help config.syntax` and :hg:`help config.files`
for information about how and where to override things.

14 15
Structure
=========
16

17 18 19
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::
20 21 22 23 24

  [ui]
  username = Firstname Lastname <firstname.lastname@example.net>
  verbose = True

Matt Mackall's avatar
Matt Mackall committed
25
The above entries will be referred to as ``ui.username`` and
26
``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 28

Files
29
=====
30 31

Mercurial reads configuration data from several files, if they exist.
32
These files do not exist by default and you will have to create the
33 34 35 36 37 38 39 40
appropriate configuration files yourself:

Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.

Global configuration like the username setting is typically put into:

.. container:: windows

41
  - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42 43 44

.. container:: unix.plan9

45
  - ``$HOME/.hgrc`` (on Unix, Plan9)
46

47 48 49 50 51 52
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.

53 54 55 56 57 58
.. container:: verbose.unix

  On Unix, the following files are consulted:

  - ``<repo>/.hg/hgrc`` (per-repository)
  - ``$HOME/.hgrc`` (per-user)
59
  - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 61 62 63
  - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
  - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
  - ``/etc/mercurial/hgrc`` (per-system)
  - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64
  - ``<internal>/*.rc`` (defaults)
65 66 67 68 69 70 71 72 73 74

.. container:: verbose.windows

  On Windows, the following files are consulted:

  - ``<repo>/.hg/hgrc`` (per-repository)
  - ``%USERPROFILE%\.hgrc`` (per-user)
  - ``%USERPROFILE%\Mercurial.ini`` (per-user)
  - ``%HOME%\.hgrc`` (per-user)
  - ``%HOME%\Mercurial.ini`` (per-user)
75
  - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
76 77
  - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
  - ``<install-dir>\Mercurial.ini`` (per-installation)
78 79 80
  - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
  - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
  - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
81
  - ``<internal>/*.rc`` (defaults)
82 83

  .. note::
84 85

   The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
86 87
   is used when running 32-bit Python on 64-bit Windows.

88 89 90 91 92 93 94 95 96 97
.. container:: verbose.plan9

  On Plan9, the following files are consulted:

  - ``<repo>/.hg/hgrc`` (per-repository)
  - ``$home/lib/hgrc`` (per-user)
  - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
  - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
  - ``/lib/mercurial/hgrc`` (per-system)
  - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
98
  - ``<internal>/*.rc`` (defaults)
99 100 101 102

Per-repository configuration options only apply in a
particular repository. This file is not version-controlled, and
will not get transferred during a "clone" operation. Options in
103 104 105 106 107 108 109
this file override options in all other configuration files.

.. container:: unix.plan9

  On Plan 9 and Unix, most of this file will be ignored if it doesn't
  belong to a trusted user or to a trusted group. See
  :hg:`help config.trusted` for more details.
110

111 112 113 114
Per-user configuration file(s) are for the user running Mercurial.  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.
115 116 117

Per-installation configuration files are searched for in the
directory where Mercurial is installed. ``<install-root>`` is the
118 119 120 121 122 123 124 125
parent directory of the **hg** executable (or symlink) being run.

.. container:: unix.plan9

  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.
126 127 128 129 130 131 132 133 134 135 136 137 138 139

Per-installation configuration files are 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.

Per-system configuration files are 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.

140 141 142 143 144 145 146
Mercurial comes with some default configuration. The default configuration
files are installed with Mercurial and will be overwritten on upgrades. Default
configuration files should never be edited by users or administrators but can
be overridden in other configuration files. So far the directory only contains
merge tool configuration but packagers can also put other default configuration
there.

147
Syntax
148
======
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163

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.

164
Configuration keys can be set multiple times, in which case Mercurial
165 166 167 168 169 170 171 172 173 174
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
175 176
be redefined on the same and/or on different configuration files. For
example::
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232

    [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``).

Sections
233
========
234 235

This section describes the different sections that may appear in a
236 237
Mercurial configuration file, the purpose of each section, its possible
keys, and their possible values.
238 239

``alias``
240
---------
241 242

Defines command aliases.
243

244 245
Aliases allow you to define your own commands in terms of other
commands (or aliases), optionally including arguments. Positional
246
arguments in the form of ``$1``, ``$2``, etc. in the alias definition
247 248 249 250 251 252
are expanded by Mercurial before execution. Positional arguments not
already used by ``$N`` in the definition are put at the end of the
command to be executed.

Alias definitions consist of lines of the form::

Wagner Bruna's avatar
Wagner Bruna committed
253
    <alias> = <command> [<argument>]...
254 255 256 257 258 259 260 261 262 263

For example, this definition::

    latest = log --limit 5

creates a new command ``latest`` that shows only the five most recent
changesets. You can define subsequent aliases using earlier ones::

    stable5 = latest -b stable

264 265 266
.. note::

   It is possible to create aliases with the same names as
267 268 269 270 271 272 273
   existing commands, which will then override the original
   definitions. This is almost always a bad idea!

An alias can start with an exclamation point (``!``) to make it a
shell alias. A shell alias is executed with the shell and will let you
run arbitrary commands. As an example, ::

274
   echo = !echo $@
275 276 277 278

will let you do ``hg echo foo`` to have ``foo`` printed in your
terminal. A better example might be::

279
   purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
280 281 282 283

which will make ``hg purge`` delete all unknown files in the
repository in the same manner as the purge extension.

284 285 286
Positional arguments like ``$1``, ``$2``, etc. in the alias definition
expand to the command arguments. Unmatched arguments are
removed. ``$0`` expands to the alias name and ``$@`` expands to all
287 288 289
arguments separated by a space. ``"$@"`` (with quotes) expands to all
arguments quoted individually and separated by a space. These expansions
happen before the command is passed to the shell.
290 291

Shell aliases are executed in an environment where ``$HG`` expands to
292 293 294
the path of the Mercurial that was used to execute the alias. This is
useful when you want to call further Mercurial commands in a shell
alias, as was done above for the purge alias. In addition,
295
``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
296 297
echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.

298 299 300
.. note::

   Some global configuration options such as ``-R`` are
301 302 303
   processed before shell aliases and will thus not be passed to
   aliases.

304 305

``annotate``
306
------------
307 308

Settings used when displaying file annotations. All values are
309 310
Booleans and default to False. See :hg:`help config.diff` for
related options for the diff command.
311 312 313 314

``ignorews``
    Ignore white space when comparing lines.

315 316 317
``ignorewseol``
    Ignore white space at the end of a line when comparing lines.

318 319 320 321 322 323 324
``ignorewsamount``
    Ignore changes in the amount of white space.

``ignoreblanklines``
    Ignore changes whose lines are all blank.


325
``auth``
326
--------
327

328 329 330 331 332
Authentication credentials and other authentication-like configuration
for HTTP connections. This section allows you to store usernames and
passwords for use when logging *into* HTTP servers. See
:hg:`help config.web` if you want to configure *who* can login to
your HTTP server.
333

334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
The following options apply to all hosts.

``cookiefile``
    Path to a file containing HTTP cookie lines. Cookies matching a
    host will be sent automatically.

    The file format uses the Mozilla cookies.txt format, which defines cookies
    on their own lines. Each line contains 7 fields delimited by the tab
    character (domain, is_domain_cookie, path, is_secure, expires, name,
    value). For more info, do an Internet search for "Netscape cookies.txt
    format."

    Note: the cookies parser does not handle port numbers on domains. You
    will need to remove ports from the domain for the cookie to be recognized.
    This could result in a cookie being disclosed to an unwanted server.

    The cookies file is read-only.

Other options in this section are grouped by name and have the following
format::
354 355 356 357 358 359

    <name>.<argument> = <value>

where ``<name>`` is used to group arguments into authentication
entries. Example::

360
    foo.prefix = hg.intevation.de/mercurial
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
    foo.username = foo
    foo.password = bar
    foo.schemes = http https

    bar.prefix = secure.example.org
    bar.key = path/to/file.key
    bar.cert = path/to/file.cert
    bar.schemes = https

Supported arguments:

``prefix``
    Either ``*`` or a URI prefix with or without the scheme part.
    The authentication entry with the longest matching prefix is used
    (where ``*`` matches everything and counts as a match of length
    1). If the prefix doesn't include a scheme, the match is performed
    against the URI with its scheme stripped as well, and the schemes
    argument, q.v., is then subsequently consulted.
379

380 381 382 383
``username``
    Optional. Username to authenticate with. If not given, and the
    remote site requires basic or digest authentication, the user will
    be prompted for it. Environment variables are expanded in the
384 385 386
    username letting you do ``foo.username = $USER``. If the URI
    includes a username, only ``[auth]`` entries with a matching
    username or without a username will be considered.
387

388 389 390 391
``password``
    Optional. Password to authenticate with. If not given, and the
    remote site requires basic or digest authentication, the user
    will be prompted for it.
392

393 394 395
``key``
    Optional. PEM encoded client certificate key file. Environment
    variables are expanded in the filename.
396

397 398 399
``cert``
    Optional. PEM encoded client certificate chain file. Environment
    variables are expanded in the filename.
400

401 402 403 404 405
``schemes``
    Optional. Space separated list of URI schemes to use this
    authentication entry with. Only used if the prefix doesn't include
    a scheme. Supported schemes are http and https. They will match
    static-http and static-https respectively, as well.
406
    (default: https)
407 408 409 410

If no suitable authentication entry is found, the user is prompted
for credentials as usual if required by the remote.

411 412 413 414 415
``cmdserver``
-------------

Controls command server settings. (ADVANCED)

416 417 418 419 420 421
``message-encodings``
    List of encodings for the ``m`` (message) channel. The first encoding
    supported by the server will be selected and advertised in the hello
    message. This is useful only when ``ui.message-output`` is set to
    ``channel``. Supported encodings are ``cbor``.

422 423 424 425 426 427 428
``shutdown-on-interrupt``
    If set to false, the server's main loop will continue running after
    SIGINT received. ``runcommand`` requests can still be interrupted by
    SIGINT. Close the write end of the pipe to shut down the server
    process gracefully.
    (default: True)

429 430 431 432 433 434 435 436
``color``
---------

Configure the Mercurial color mode. For details about how to define your custom
effect and style see :hg:`help color`.

``mode``
    String: control the method used to output color. One of ``auto``, ``ansi``,
437
    ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
438
    use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
439 440 441
    terminal. Any invalid value will disable color.

``pagermode``
Matt Harbison's avatar
Matt Harbison committed
442
    String: optional override of ``color.mode`` used with pager.
443 444

    On some systems, terminfo mode may cause problems when using
445
    color with ``less -R`` as a pager program. less with the -R option
446 447 448 449 450 451 452
    will only display ECMA-48 color codes, and terminfo mode may sometimes
    emit codes that less doesn't understand. You can work around this by
    either using ansi mode (or auto mode), or by using less -r (which will
    pass through all terminal control codes, not just color control
    codes).

    On some systems (such as MSYS in Windows), the terminal may support
453
    a different color mode than the pager program.
454

455
``commands``
456
------------
457

458 459 460 461
``commit.post-status``
    Show status of files in the working directory after successful commit.
    (default: False)

462 463 464 465 466 467
``merge.require-rev``
    Require that the revision to merge the current commit with be specified on
    the command line. If this is enabled and a revision is not specified, the
    command aborts.
    (default: False)

468 469 470 471 472 473 474 475
``push.require-revs``
    Require revisions to push be specified using one or more mechanisms such as
    specifying them positionally on the command line, using ``-r``, ``-b``,
    and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
    configuration. If this is enabled and revisions are not specified, the
    command aborts.
    (default: False)

476
``resolve.confirm``
477
    Confirm before performing action if no filename is passed.
478 479
    (default: False)

480 481 482 483 484
``resolve.explicit-re-merge``
    Require uses of ``hg resolve`` to specify which action it should perform,
    instead of re-merging files by default.
    (default: False)

485 486 487 488 489 490 491 492 493 494
``resolve.mark-check``
    Determines what level of checking :hg:`resolve --mark` will perform before
    marking files as resolved. Valid values are ``none`, ``warn``, and
    ``abort``. ``warn`` will output a warning listing the file(s) that still
    have conflict markers in them, but will still mark everything resolved.
    ``abort`` will output the same warning but will not mark things as resolved.
    If --all is passed and this is set to ``abort``, only a warning will be
    shown (an error will not be raised).
    (default: ``none``)

495
``status.relative``
496
    Make paths in :hg:`status` output relative to the current directory.
497 498
    (default: False)

499
``status.terse``
Ludovic Chabant's avatar
Ludovic Chabant committed
500
    Default value for the --terse flag, which condenses status output.
501 502
    (default: empty)

503 504 505 506 507 508 509 510 511 512 513 514
``update.check``
    Determines what level of checking :hg:`update` will perform before moving
    to a destination revision. Valid values are ``abort``, ``none``,
    ``linear``, and ``noconflict``. ``abort`` always fails if the working
    directory has uncommitted changes. ``none`` performs no checking, and may
    result in a merge with uncommitted changes. ``linear`` allows any update
    as long as it follows a straight line in the revision history, and may
    trigger a merge with uncommitted changes. ``noconflict`` will allow any
    update which would not trigger a merge with uncommitted changes, if any
    are present.
    (default: ``linear``)

515
``update.requiredest``
516 517
    Require that the user pass a destination when running :hg:`update`.
    For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
518 519 520
    will be disallowed.
    (default: False)

521 522 523
``committemplate``
------------------

524 525 526
``changeset``
    String: configuration in this section is used as the template to
    customize the text shown in the editor when committing.
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544

In addition to pre-defined template keywords, commit log specific one
below can be used for customization:

``extramsg``
    String: Extra message (typically 'Leave message empty to abort
    commit.'). This may be changed by some commands or extensions.

For example, the template configuration below shows as same text as
one shown by default::

    [committemplate]
    changeset = {desc}\n\n
        HG: Enter commit message.  Lines beginning with 'HG:' are removed.
        HG: {extramsg}
        HG: --
        HG: user: {author}\n{ifeq(p2rev, "-1", "",
       "HG: branch merge\n")
545 546
       }HG: branch '{branch}'\n{if(activebookmark,
       "HG: bookmark '{activebookmark}'\n")   }{subrepos %
547 548 549 550 551 552
       "HG: subrepo {subrepo}\n"              }{file_adds %
       "HG: added {file}\n"                   }{file_mods %
       "HG: changed {file}\n"                 }{file_dels %
       "HG: removed {file}\n"                 }{if(files, "",
       "HG: no files changed\n")}

553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
``diff()``
    String: show the diff (see :hg:`help templates` for detail)

Sometimes it is helpful to show the diff of the changeset in the editor without
having to prefix 'HG: ' to each line so that highlighting works correctly. For
this, Mercurial provides a special string which will ignore everything below
it::

     HG: ------------------------ >8 ------------------------

For example, the template configuration below will show the diff below the
extra message::

    [committemplate]
    changeset = {desc}\n\n
        HG: Enter commit message.  Lines beginning with 'HG:' are removed.
        HG: {extramsg}
        HG: ------------------------ >8 ------------------------
        HG: Do not touch the line above.
        HG: Everything below will be removed.
        {diff()}

575 576 577 578 579 580
.. note::

   For some problematic encodings (see :hg:`help win32mbcs` for
   detail), this customization should be configured carefully, to
   avoid showing broken characters.

581 582 583 584
   For example, if a multibyte character ending with backslash (0x5c) is
   followed by the ASCII character 'n' in the customized template,
   the sequence of backslash and 'n' is treated as line-feed unexpectedly
   (and the multibyte character is broken, too).
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601

Customized template is used for commands below (``--edit`` may be
required):

- :hg:`backout`
- :hg:`commit`
- :hg:`fetch` (for merge commit only)
- :hg:`graft`
- :hg:`histedit`
- :hg:`import`
- :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
- :hg:`rebase`
- :hg:`shelve`
- :hg:`sign`
- :hg:`tag`
- :hg:`transplant`

602 603
Configuring items below instead of ``changeset`` allows showing
customized message only for specific actions, or showing different
Wagner Bruna's avatar
Wagner Bruna committed
604
messages for each action.
605 606

- ``changeset.backout`` for :hg:`backout`
607 608
- ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
- ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
609 610
- ``changeset.commit.normal.merge`` for :hg:`commit` on merges
- ``changeset.commit.normal.normal`` for :hg:`commit` on other
611 612 613 614 615 616 617 618
- ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
- ``changeset.gpg.sign`` for :hg:`sign`
- ``changeset.graft`` for :hg:`graft`
- ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
- ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
- ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
- ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
- ``changeset.import.bypass`` for :hg:`import --bypass`
619 620
- ``changeset.import.normal.merge`` for :hg:`import` on merges
- ``changeset.import.normal.normal`` for :hg:`import` on other
621 622 623 624
- ``changeset.mq.qnew`` for :hg:`qnew`
- ``changeset.mq.qfold`` for :hg:`qfold`
- ``changeset.mq.qrefresh`` for :hg:`qrefresh`
- ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
625 626
- ``changeset.rebase.merge`` for :hg:`rebase` on merges
- ``changeset.rebase.normal`` for :hg:`rebase` on other
627 628 629
- ``changeset.shelve.shelve`` for :hg:`shelve`
- ``changeset.tag.add`` for :hg:`tag` without ``--remove``
- ``changeset.tag.remove`` for :hg:`tag --remove`
630 631
- ``changeset.transplant.merge`` for :hg:`transplant` on merges
- ``changeset.transplant.normal`` for :hg:`transplant` on other
632 633 634 635 636 637

These dot-separated lists of names are treated as hierarchical ones.
For example, ``changeset.tag.remove`` customizes the commit message
only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
commit message for :hg:`tag` regardless of ``--remove`` option.

638 639 640 641
When the external editor is invoked for a commit, the corresponding
dot-separated list of names without the ``changeset.`` prefix
(e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
variable.
642

643 644 645 646 647 648 649 650 651 652 653
In this section, items other than ``changeset`` can be referred from
others. For example, the configuration to list committed files up
below can be referred as ``{listupfiles}``::

    [committemplate]
    listupfiles = {file_adds %
       "HG: added {file}\n"     }{file_mods %
       "HG: changed {file}\n"   }{file_dels %
       "HG: removed {file}\n"   }{if(files, "",
       "HG: no files changed\n")}

654
``decode/encode``
655
-----------------
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691

Filters for transforming files on checkout/checkin. This would
typically be used for newline processing or other
localization/canonicalization of files.

Filters consist of a filter pattern followed by a filter command.
Filter patterns are globs by default, rooted at the repository root.
For example, to match any file ending in ``.txt`` in the root
directory only, use the pattern ``*.txt``. To match any file ending
in ``.c`` anywhere in the repository, use the pattern ``**.c``.
For each file only the first matching filter applies.

The filter command can start with a specifier, either ``pipe:`` or
``tempfile:``. If no specifier is given, ``pipe:`` is used by default.

A ``pipe:`` command must accept data on stdin and return the transformed
data on stdout.

Pipe example::

  [encode]
  # uncompress gzip files on checkin to improve delta compression
  # note: not necessarily a good idea, just an example
  *.gz = pipe: gunzip

  [decode]
  # recompress gzip files when writing them to the working dir (we
  # can safely omit "pipe:", because it's the default)
  *.gz = gzip

A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
with the name of a temporary file that contains the data to be
filtered by the command. The string ``OUTFILE`` is replaced with the name
of an empty temporary file, where the filtered data must be written by
the command.

timeless's avatar
timeless committed
692
.. container:: windows
693

timeless's avatar
timeless committed
694 695 696 697 698
   .. note::

     The tempfile mechanism is recommended for Windows systems,
     where the standard shell I/O redirection operators often have
     strange effects and may corrupt the contents of your files.
699 700 701 702 703 704 705

This filter mechanism is used internally by the ``eol`` extension to
translate line ending characters between Windows (CRLF) and Unix (LF)
format. We suggest you use the ``eol`` extension for convenience.


``defaults``
706
------------
707

708
(defaults are deprecated. Don't use them. Use aliases instead.)
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725

Use the ``[defaults]`` section to define command defaults, i.e. the
default options/arguments to pass to the specified commands.

The following example makes :hg:`log` run in verbose mode, and
:hg:`status` show only the modified files, by default::

  [defaults]
  log = -v
  status = -m

The actual commands, instead of their aliases, must be used when
defining command defaults. The command defaults will also be applied
to the aliases of the commands defined.


``diff``
726
--------
727

728
Settings used when displaying diffs. Everything except for ``unified``
729 730
is a Boolean and defaults to False. See :hg:`help config.annotate`
for related options for the annotate command.
731 732 733

``git``
    Use git extended diff format.
734

735 736 737
``nobinary``
    Omit git binary patches.

738 739
``nodates``
    Don't include dates in diff headers.
740

741 742 743
``noprefix``
    Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.

744 745
``showfunc``
    Show which function each change is in.
746

747 748
``ignorews``
    Ignore white space when comparing lines.
749

750 751
``ignorewsamount``
    Ignore changes in the amount of white space.
752

753 754
``ignoreblanklines``
    Ignore changes whose lines are all blank.
755

756 757 758
``unified``
    Number of lines of context to show.

759 760 761
``word-diff``
    Highlight changed words.

762
``email``
763
---------
764 765 766 767 768 769

Settings for extensions that send email messages.

``from``
    Optional. Email address to use in "From" header and SMTP envelope
    of outgoing messages.
770

771 772
``to``
    Optional. Comma-separated list of recipients' email addresses.
773

774 775 776
``cc``
    Optional. Comma-separated list of carbon copy recipients'
    email addresses.
777

778 779 780
``bcc``
    Optional. Comma-separated list of blind carbon copy recipients'
    email addresses.
781

782 783
``method``
    Optional. Method to use to send email messages. If value is ``smtp``
784
    (default), use SMTP (see the ``[smtp]`` section for configuration).
785 786 787 788
    Otherwise, use as name of program to run that acts like sendmail
    (takes ``-f`` option for sender, list of recipients on command line,
    message on stdin). Normally, setting this to ``sendmail`` or
    ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
789

790 791 792 793 794 795
``charsets``
    Optional. Comma-separated list of character sets considered
    convenient for recipients. Addresses, headers, and parts not
    containing patches of outgoing messages will be encoded in the
    first character set to which conversion from local encoding
    (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
796 797
    conversion fails, the text in question is sent as is.
    (default: '')
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817

    Order of outgoing email character sets:

    1. ``us-ascii``: always first, regardless of settings
    2. ``email.charsets``: in order given by user
    3. ``ui.fallbackencoding``: if not in email.charsets
    4. ``$HGENCODING``: if not in email.charsets
    5. ``utf-8``: always last, regardless of settings

Email example::

  [email]
  from = Joseph User <joe.user@example.com>
  method = /usr/sbin/sendmail
  # charsets for western Europeans
  # us-ascii, utf-8 omitted, as they are tried first and last
  charsets = iso-8859-1, iso-8859-15, windows-1252


``extensions``
818
--------------
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837

Mercurial has an extension mechanism for adding new features. To
enable an extension, create an entry for it in this section.

If you know that the extension is already in Python's search path,
you can give the name of the module, followed by ``=``, with nothing
after the ``=``.

Otherwise, give a name that you choose, followed by ``=``, followed by
the path to the ``.py`` file (including the file name extension) that
defines the extension.

To explicitly disable an extension that is enabled in an hgrc of
broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
or ``foo = !`` when path is not supplied.

Example for ``~/.hgrc``::

  [extensions]
838 839
  # (the churn extension will get loaded from Mercurial's path)
  churn =
840 841 842 843 844
  # (this extension will get loaded from the file specified)
  myfeature = ~/.hgext/myfeature.py


``format``
845
----------
846

847
Configuration that controls the repository format. Newer format options are more
848
powerful, but incompatible with some older versions of Mercurial. Format options
849
are considered at repository initialization only. You need to make a new clone
850
for config changes to be taken into account.
851 852 853 854

For more details about repository format and version compatibility, see
https://www.mercurial-scm.org/wiki/MissingRequirement

855 856
``usegeneraldelta``
    Enable or disable the "generaldelta" repository format which improves
857 858 859
    repository compression by allowing "revlog" to store deltas against
    arbitrary revisions instead of the previously stored one. This provides
    significant improvement for repositories with branches.
860 861 862 863

    Repositories with this on-disk format require Mercurial version 1.9.

    Enabled by default.
864

865 866 867
``dotencode``
    Enable or disable the "dotencode" repository format which enhances
    the "fncache" repository format (which has to be enabled to use
868
    dotencode) to avoid issues with filenames starting with "._" on
869 870 871 872 873
    Mac OS X and spaces on Windows.

    Repositories with this on-disk format require Mercurial version 1.7.

    Enabled by default.
874 875 876 877 878

``usefncache``
    Enable or disable the "fncache" repository format which enhances
    the "store" repository format (which has to be enabled to use
    fncache) to allow longer filenames and avoids using Windows
879 880 881 882 883
    reserved names, e.g. "nul".

    Repositories with this on-disk format require Mercurial version 1.1.

    Enabled by default.
884

885 886 887
``usestore``
    Enable or disable the "store" repository format which improves
    compatibility with systems that fold case or otherwise mangle
888 889 890 891 892 893
    filenames. Disabling this option will allow you to store longer filenames
    in some situations at the expense of compatibility.

    Repositories with this on-disk format require Mercurial version 0.9.4.

    Enabled by default.
894

895 896 897 898 899 900 901 902 903
``sparse-revlog``
    Enable or disable the ``sparse-revlog`` delta strategy. This format improves
    delta re-use inside revlog. For very branchy repositories, it results in a
    smaller store. For repositories with many revisions, it also helps
    performance (by using shortened delta chains.)

    Repositories with this on-disk format require Mercurial version 4.7

    Enabled by default.
904

905
``revlog-compression``
906 907 908
    Compression algorithm used by revlog. Supported values are `zlib` and
    `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
    a newer format that is usually a net win over `zlib`, operating faster at
909 910
    better compression rates. Use `zstd` to reduce CPU usage. Multiple values
    can be specified, the first available one will be used.
911

912 913 914
    On some systems, the Mercurial installation may lack `zstd` support.

    Default is `zlib`.
915

916 917 918 919 920 921 922 923 924
``bookmarks-in-store``
    Store bookmarks in .hg/store/. This means that bookmarks are shared when
    using `hg share` regardless of the `-B` option.

    Repositories with this on-disk format require Mercurial version 5.1.

    Disabled by default.


925
``graph``
926
---------
927

928 929 930
Web graph view configuration. This section let you change graph
elements display properties by branches, for instance to make the
``default`` branch stand out.
931

932
Each line has the following format::
933

934 935 936 937 938 939 940 941 942 943
    <branch>.<argument> = <value>

where ``<branch>`` is the name of the branch being
customized. Example::

    [graph]
    # 2px width
    default.width = 2
    # red color
    default.color = FF0000
944 945 946 947

Supported arguments:

``width``
948
    Set branch edges width in pixels.
949

950
``color``
951
    Set branch edges color in hexadecimal RGB notation.
952

953
``hooks``
954
---------
955 956 957 958 959

Commands or Python functions that get automatically executed by
various actions such as starting or finishing a commit. Multiple
hooks can be run for the same action by appending a suffix to the
action. Overriding a site-wide hook can be done by changing its
960
value or setting it to an empty string.  Hooks can be prioritized
961
by adding a prefix of ``priority.`` to the hook name on a new line
962
and setting the priority. The default priority is 0.
963 964 965 966 967 968 969 970 971 972

Example ``.hg/hgrc``::

  [hooks]
  # update working directory after adding changesets
  changegroup.update = hg update
  # do not use the site-wide hook
  incoming =
  incoming.email = /my/email/hook
  incoming.autobuild = /my/build/hook
973 974
  # force autobuild hook to run before other incoming hooks
  priority.incoming.autobuild = 1
975 976

Most hooks are run with environment variables set that give useful
977
additional information. For each hook below, the environment variables
978
it is passed are listed with names in the form ``$HG_foo``. The
979
``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
980 981
They contain the type of hook which triggered the run and the full name
of the hook in the config, respectively. In the example above, this will
982
be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
983

984 985
.. container:: windows

986
  Some basic Unix syntax can be enabled for portability, including ``$VAR``
987 988 989 990 991
  and ``${VAR}`` style variables.  A ``~`` followed by ``\`` or ``/`` will
  be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
  on Unix.  To use a literal ``$`` or ``~``, it must be escaped with a back
  slash or inside of a strong quote.  Strong quotes will be replaced by
  double quotes after processing.
992 993 994

  This feature is enabled by adding a prefix of ``tonative.`` to the hook
  name on a new line, and setting it to ``True``.  For example::
995 996 997

    [hooks]
    incoming.autobuild = /my/build/hook
998 999
    # enable translation to cmd.exe syntax for autobuild hook
    tonative.incoming.autobuild = True
1000

1001
``changegroup``
1002 1003 1004
  Run after a changegroup has been added via push, pull or unbundle.  The ID of
  the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
  The URL from which changes came is in ``$HG_URL``.
1005

1006
``commit``
1007
  Run after a changeset has been created in the local repository. The ID
1008 1009
  of the newly created changeset is in ``$HG_NODE``. Parent changeset
  IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1010

1011 1012 1013
``incoming``
  Run after a changeset has been pulled, pushed, or unbundled into
  the local repository. The ID of the newly arrived changeset is in
1014
  ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1015

1016
``outgoing``
1017 1018 1019
  Run after sending changes from the local repository to another. The ID of
  first changeset sent is in ``$HG_NODE``. The source of operation is in
  ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1020

1021 1022 1023
``post-<command>``
  Run after successful invocations of the associated command. The
  contents of the command line are passed as ``$HG_ARGS`` and the result
1024
  code in ``$HG_RESULT``. Parsed command line arguments are passed as
1025
  ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1026
  the python data internally passed to <command>. ``$HG_OPTS`` is a
1027 1028
  dictionary of options (with unspecified options set to their defaults).
  ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1029

1030 1031 1032 1033 1034 1035 1036 1037 1038
``fail-<command>``
  Run after a failed invocation of an associated command. The contents
  of the command line are passed as ``$HG_ARGS``. Parsed command line
  arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
  string representations of the python data internally passed to
  <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
  options set to their defaults). ``$HG_PATS`` is a list of arguments.
  Hook failure is ignored.

1039 1040 1041 1042 1043
``pre-<command>``
  Run before executing the associated command. The contents of the
  command line are passed as ``$HG_ARGS``. Parsed command line arguments
  are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
  representations of the data internally passed to <command>. ``$HG_OPTS``
1044
  is a dictionary of options (with unspecified options set to their
1045
  defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1046 1047
  failure, the command doesn't execute and Mercurial returns the failure
  code.
1048

1049 1050
``prechangegroup``
  Run before a changegroup is added via push, pull or unbundle. Exit
1051 1052
  status 0 allows the changegroup to proceed. A non-zero status will
  cause the push, pull or unbundle to fail. The URL from which changes
1053
  will come is in ``$HG_URL``.
1054

1055 1056
``precommit``
  Run before starting a local commit. Exit status 0 allows the
1057
  commit to proceed. A non-zero status will cause the commit to fail.
1058
  Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1059

1060 1061
``prelistkeys``
  Run before listing pushkeys (like bookmarks) in the
1062
  repository. A non-zero status will cause failure. The key namespace is
1063
  in ``$HG_NAMESPACE``.
1064

1065 1066
``preoutgoing``
  Run before collecting changes to send from the local repository to
1067 1068 1069 1070 1071 1072 1073
  another. A non-zero status will cause failure. This lets you prevent
  pull over HTTP or SSH. It can also prevent propagating commits (via
  local pull, push (outbound) or bundle commands), but not completely,
  since you can just copy files instead. The source of operation is in
  ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
  SSH or HTTP repository. If "push", "pull" or "bundle", the operation
  is happening on behalf of a repository on same system.
1074

1075 1076
``prepushkey``
  Run before a pushkey (like a bookmark) is added to the
1077
  repository. A non-zero status will cause the key to be rejected. The
1078 1079 1080
  key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
  the old value (if any) is in ``$HG_OLD``, and the new value is in
  ``$HG_NEW``.
1081

1082 1083
``pretag``
  Run before creating a tag. Exit status 0 allows the tag to be
1084 1085 1086
  created. A non-zero status will cause the tag to fail. The ID of the
  changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
  tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1087

1088 1089
``pretxnopen``
  Run before any new repository transaction is open. The reason for the
1090
  transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1091 1092
  transaction will be in ``HG_TXNID``. A non-zero status will prevent the
  transaction from being opened.
1093

1094
``pretxnclose``
1095 1096
  Run right before the transaction is actually finalized. Any repository change
  will be visible to the hook program. This lets you validate the transaction
1097
  content or change it. Exit status 0 allows the commit to proceed. A non-zero
1098
  status will cause the transaction to be rolled back. The reason for the
1099
  transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1100
  the transaction will be in ``HG_TXNID``. The rest of the available data will
1101 1102 1103 1104 1105
  vary according the transaction type. New changesets will add ``$HG_NODE``
  (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
  added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables.  Bookmark and
  phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
  respectively, etc.
1106

1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
``pretxnclose-bookmark``
  Run right before a bookmark change is actually finalized. Any repository
  change will be visible to the hook program. This lets you validate the
  transaction content or change it. Exit status 0 allows the commit to
  proceed. A non-zero status will cause the transaction to be rolled back.
  The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
  bookmark location will be available in ``$HG_NODE`` while the previous
  location will be available in ``$HG_OLDNODE``. In case of a bookmark
  creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
  will be empty.
  In addition, the reason for the transaction opening will be in
  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
  ``HG_TXNID``.

1121 1122 1123 1124
``pretxnclose-phase``
  Run right before a phase change is actually finalized. Any repository change
  will be visible to the hook program. This lets you validate the transaction
  content or change it. Exit status 0 allows the commit to proceed.  A non-zero
1125 1126
  status will cause the transaction to be rolled back. The hook is called
  multiple times, once for each revision affected by a phase change.
1127 1128 1129 1130
  The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
  while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
  will be empty.  In addition, the reason for the transaction opening will be in
  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1131 1132
  ``HG_TXNID``. The hook is also run for newly added revisions. In this case
  the ``$HG_OLDPHASE`` entry will be empty.
1133

1134
``txnclose``
1135
  Run after any repository transaction has been committed. At this
1136
  point, the transaction can no longer be rolled back. The hook will run
1137
  after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1138
  details about available variables.
1139

1140 1141 1142
``txnclose-bookmark``
  Run after any bookmark change has been committed. At this point, the
  transaction can no longer be rolled back. The hook will run after the lock
1143 1144
  is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
  about available variables.
1145

1146 1147 1148
``txnclose-phase``
  Run after any phase change has been committed. At this point, the
  transaction can no longer be rolled back. The hook will run after the lock
1149 1150
  is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
  available variables.
1151