mercurial/help/flags.txt
author Gregory Szorc <gregory.szorc@gmail.com>
Tue, 10 Apr 2018 13:41:21 -0700
changeset 37554 301a1d2e8016
parent 35045 b0262b25ab48
permissions -rw-r--r--
httppeer: don't accept very old media types (BC) Versions of Mercurial older than 1.0 emitted the text/plain and application/hg-changegroup media types in response to wire protocol commands. Way back in 8760d0c83b9b in 2005, the code validating these media types was added, presumably for backwards compatibility. 0b245edec124 a short time before that commit changed things from text/plain and application/hg-changegroup to application/mercurial-0.1 and application/hg-0.1. 8760d0c83b9b seemed to indicate ("for now") that the BC compatibility was temporary. But that code has lived until this day. It has been more than 10 years and nobody should be running pre 1.0 servers. Pretty much the only risk to this is if there's a server somewhere advertising the old media types or server software is interfering and not letting Mercurial send the proper Content-Type header. I think the chances are rare. The wire protocol docs were created (by me) from reading existing code. So the deletions don't constitute a spec change as much as reflecting the reality of how things have been for years. .. bc:: The HTTP client no longer accepts text/plain and application/hg-changegroup Content-Type values as a valid Mercurial command response. These should only be encountered on pre 1.0 Mercurial servers. Differential Revision: https://phab.mercurial-scm.org/D3239

Most Mercurial commands accept various flags.

Flag names
==========

Flags for each command are listed in :hg:`help` for that command.
Additionally, some flags, such as --repository, are global and can be used with
any command - those are seen in :hg:`help -v`, and can be specified before or
after the command.

Every flag has at least a long name, such as --repository. Some flags may also
have a short one-letter name, such as the equivalent -R. Using the short or long
name is equivalent and has the same effect.

Flags that have a short name can also be bundled together - for instance, to
specify both --edit (short -e) and --interactive (short -i), one could use::

    hg commit -ei

If any of the bundled flags takes a value (i.e. is not a boolean), it must be
last, followed by the value::

    hg commit -im 'Message'

Flag types
==========

Mercurial command-line flags can be strings, numbers, booleans, or lists of
strings.

Specifying flag values
======================

The following syntaxes are allowed, assuming a flag 'flagname' with short name
'f'::

    --flagname=foo
    --flagname foo
    -f foo
    -ffoo

This syntax applies to all non-boolean flags (strings, numbers or lists).

Specifying boolean flags
========================

Boolean flags do not take a value parameter. To specify a boolean, use the flag
name to set it to true, or the same name prefixed with 'no-' to set it to
false::

    hg commit --interactive
    hg commit --no-interactive

Specifying list flags
=====================

List flags take multiple values. To specify them, pass the flag multiple times::

    hg files --include mercurial --include tests

Setting flag defaults
=====================

In order to set a default value for a flag in an hgrc file, it is recommended to
use aliases::

    [alias]
    commit = commit --interactive

For more information on hgrc files, see :hg:`help config`.

Overriding flags on the command line
====================================

If the same non-list flag is specified multiple times on the command line, the
latest specification is used::

    hg commit -m "Ignored value" -m "Used value"

This includes the use of aliases - e.g., if one has::

    [alias]
    committemp = commit -m "Ignored value"

then the following command will override that -m::

    hg committemp -m "Used value"

Overriding flag defaults
========================

Every flag has a default value, and you may also set your own defaults in hgrc
as described above.
Except for list flags, defaults can be overridden on the command line simply by
specifying the flag in that location.

Hidden flags
============

Some flags are not shown in a command's help by default - specifically, those
that are deemed to be experimental, deprecated or advanced. To show all flags,
add the --verbose flag for the help command::

    hg help --verbose commit