{i} This page does not meet our wiki style guidelines. Please help improve this page by cleaning up its formatting.

Mercurial allows to set default options and arguments for commands in the configuration file.

Full quote of http://www.selenic.com/mercurial/hgrc.5.html#defaults (as of Mercurial 1.6.3):

(defaults are deprecated. Don't use them. Use aliases instead)

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:

  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.


Defaults are a controversial feature. While some users might find them useful, project lead Matt Mackall has repeatedly expressed that defaults cause more harm than good and should not be used. In http://markmail.org/message/hl3d6eprubmkkqh5 (Oct 21, 2009):

Defaults are a bad idea. They are deprecated. Don't use them. Don't
recommend them. Forget they existed. Use aliases.

Which lead to their deprecation with change 24dad078603b.

In http://mercurial.markmail.org/message/jkaw5nflizlirgzt (Oct 21, 2009):

... Again, this is one of the fundamental problems with defaults: once you've set a default, there's no way to bypass it. Don't use 'em. And please don't suggest them to other people.
Instead, make a new command:

wclone = clone -u . 

In http://mercurial.markmail.org/message/eit7ip5sk2xzeyyi (Aug 13, 2010)

Breaking automation is only one of the reason to not use defaults.

Another is they form bad habits. One of the earliest versions of Slackware (circa 1993) used to ship with a shell configured with a default alias of 'rm = rm -i' under the assumption that most users were complete Linux newbs and they should be warned that they were deleting their files permanently. Result: lots of users' fingers 'learned' they could use 'rm' without any forethought and put off having their real learning experience about rm until they were on a different machine - possibly someone else's.

And a third is that our options aren't toggles (and aren't going to be). So if you want to disable one default option, you've got to switch -everything- into plain mode.

And a fourth is that aliases do everything that defaults did and more, while providing the ability to avoid shadowing built-ins (thus avoiding the above three points). So there really no reason to use defaults these days. We should probably drop the docs. 

Defaults (last edited 2013-12-02 15:12:52 by MartinGeisler)