view mercurial/help/flags.txt @ 35616:706aa203b396

fileset: add a lightweight file filtering language This patch was inspired by one that Jun Wu authored for the fb-experimental repo, to avoid using matcher for efficiency[1]. We want a way to specify what files will be converted to LFS at commit time. And per discussion, we also want to specify what files to skip, text diff, or merge in another config option. The current `lfs.threshold` config option could not satisfy complex needs. I'm putting it in a core package because Augie floated the idea of also using it for narrow and sparse. Yuya suggested farming out to fileset.parse(), which added support for more symbols. The only fileset element not supported here is 'negate'. (List isn't supported by filesets either.) I also changed the 'always' token to the 'all()' predicate for consistency, and introduced 'none()' to improve readability in a future tracked file based config. The extension operator was changed from '.' to '**', to match how recursive path globs are specified. Finally, I changed the path matcher from '/' to 'path:' at Yuya's suggestion, for consistency with matcher. Unfortunately, ':' is currently reserved in filesets, so this has to be quoted to be processed as a string instead of a symbol[2]. We should probably revisit that, because it's seriously ugly. But it's only used by an experimental extension, and I think using a file based config for LFS may drive some more tweaks, so I'm settling for this for now. I reserved all of the glob characters in fileset except '.' and '_' for the extension test because those are likely valid extension characters. Sample filter settings: all() # everything size(">20MB") # larger than 20MB !**.txt # except for .txt files **.zip | **.tar.gz | **.7z # some types of compressed files "path:bin" # files under "bin" in the project root [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-December/109387.html [2] https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-January/109729.html
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 10 Jan 2018 22:23:34 -0500
parents b0262b25ab48
children
line wrap: on
line source

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