mercurial/help/revsets.txt
author Adrian Buehlmann <adrian@cadifra.com>
Mon, 02 May 2011 00:04:49 +0200
changeset 14160 a881a058823c
parent 14098 9f5a0acb0056
child 14692 0be6dc3d8083
permissions -rw-r--r--
hgrc.5: mention new 'case collision' handling for ui.portablefilenames
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     1
Mercurial supports a functional language for selecting a set of
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     2
revisions.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     3
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     4
The language supports a number of predicates which are joined by infix
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     5
operators. Parenthesis can be used for grouping.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     6
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     7
Identifiers such as branch names must be quoted with single or double
11420
a99ef3711890 revset: improve help on strings
Matt Mackall <mpm@selenic.com>
parents: 11382
diff changeset
     8
quotes if they contain characters outside of
a99ef3711890 revset: improve help on strings
Matt Mackall <mpm@selenic.com>
parents: 11382
diff changeset
     9
``[._a-zA-Z0-9\x80-\xff]`` or if they match one of the predefined
12408
78a97859b90d revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents: 11944
diff changeset
    10
predicates.
78a97859b90d revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents: 11944
diff changeset
    11
78a97859b90d revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents: 11944
diff changeset
    12
Special characters can be used in quoted identifiers by escaping them,
78a97859b90d revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents: 11944
diff changeset
    13
e.g., ``\n`` is interpreted as a newline. To prevent them from being
78a97859b90d revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents: 11944
diff changeset
    14
interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    15
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    16
There is a single prefix operator:
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    17
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    18
``not x``
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    19
  Changesets not in x. Short form is ``! x``.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    20
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    21
These are the supported infix operators:
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    22
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    23
``x::y``
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    24
  A DAG range, meaning all changesets that are descendants of x and
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    25
  ancestors of y, including x and y themselves. If the first endpoint
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    26
  is left out, this is equivalent to ``ancestors(y)``, if the second
11450
6bca9801c92a revset: fix spelling typo
Julian Cowley <julian@lava.net>
parents: 11420
diff changeset
    27
  is left out it is equivalent to ``descendants(x)``.
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    28
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    29
  An alternative syntax is ``x..y``.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    30
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    31
``x:y``
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    32
  All changesets with revision numbers between x and y, both
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    33
  inclusive. Either endpoint can be left out, they default to 0 and
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    34
  tip.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    35
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    36
``x and y``
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    37
  The intersection of changesets in x and y. Short form is ``x & y``.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    38
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    39
``x or y``
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    40
  The union of changesets in x and y. There are two alternative short
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    41
  forms: ``x | y`` and ``x + y``.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    42
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    43
``x - y``
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    44
  Changesets in x but not in y.
14070
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    45
  
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    46
``x^n``
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    47
  The nth parent of x, n == 0, 1, or 2.
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    48
  For n == 0, x; for n == 1, the first parent of each changeset in x;
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    49
  for n == 2, the second parent of changeset in x.
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    50
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    51
``x~n``
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    52
  The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    53
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    54
There is a single postfix operator:
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    55
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    56
``x^``
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    57
  Equivalent to ``x^1``, the first parent of each changeset in x.
305c97670d7a revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents: 13937
diff changeset
    58
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    59
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    60
The following predicates are supported:
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    61
12821
165079e564f0 revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 12808
diff changeset
    62
.. predicatesmarker
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    63
14098
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    64
New predicates (known as "aliases") can be defined, using any combination of
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    65
existing predicates or other aliases. An alias definition looks like::
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    66
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    67
  <alias> = <definition>
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    68
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    69
in the ``revsetalias`` section of ``.hgrc``. Arguments of the form `$1`, `$2`,
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    70
etc. are substituted from the alias into the definition.
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    71
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    72
For example,
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    73
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    74
::
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    75
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    76
  [revsetalias]
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    77
  h = heads()
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    78
  d($1) = sort($1, date)
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    79
  rs($1, $2) = reverse(sort($1, $2))
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    80
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    81
defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    82
exactly equivalent to ``reverse(sort(0:tip, author))``.
9f5a0acb0056 revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents: 14070
diff changeset
    83
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    84
Command line equivalents for :hg:`log`::
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    85
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    86
  -f    ->  ::.
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    87
  -d x  ->  date(x)
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    88
  -k x  ->  keyword(x)
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    89
  -m    ->  merge()
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    90
  -u x  ->  user(x)
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    91
  -b x  ->  branch(x)
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    92
  -P x  ->  !::x
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    93
  -l x  ->  limit(expr, x)
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    94
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
    95
Some sample queries:
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
    96
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
    97
- Changesets on the default branch::
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
    98
12808
74f6531581e8 help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents: 12716
diff changeset
    99
    hg log -r "branch(default)"
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   100
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   101
- Changesets on the default branch since tag 1.5 (excluding merges)::
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   102
12808
74f6531581e8 help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents: 12716
diff changeset
   103
    hg log -r "branch(default) and 1.5:: and not merge()"
11382
2f09b13e914d help: new revsets topic
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   104
12660
6ed5ae6264c2 revsets: add a sample query to the help for getting active branches
Brodie Rao <brodie@bitheap.org>
parents: 12659
diff changeset
   105
- Open branch heads::
6ed5ae6264c2 revsets: add a sample query to the help for getting active branches
Brodie Rao <brodie@bitheap.org>
parents: 12659
diff changeset
   106
12808
74f6531581e8 help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents: 12716
diff changeset
   107
    hg log -r "head() and not closed()"
12660
6ed5ae6264c2 revsets: add a sample query to the help for getting active branches
Brodie Rao <brodie@bitheap.org>
parents: 12659
diff changeset
   108
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   109
- Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
12667
f5735bb80d77 revsets: fix stray * in help topic
Martin Geisler <mg@lazybytes.net>
parents: 12660
diff changeset
   110
  ``hgext/*``::
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   111
12808
74f6531581e8 help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents: 12716
diff changeset
   112
    hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   113
13937
5f126c01ebfa help/revset: fix grammar
Idan Kamara <idankk86@gmail.com>
parents: 12821
diff changeset
   114
- Changesets committed in May 2008, sorted by user::
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   115
12808
74f6531581e8 help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents: 12716
diff changeset
   116
    hg log -r "sort(date('May 2008'), user)"
12659
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   117
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   118
- Changesets mentioning "bug" or "issue" that are not in a tagged
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   119
  release::
5aa5cbaf6efc revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents: 12657
diff changeset
   120
12808
74f6531581e8 help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents: 12716
diff changeset
   121
    hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tagged())"