Mercurial > hg
annotate mercurial/help/revsets.txt @ 23742:3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
Before this patch, there is no way to concatenate strings at runtime.
For example, to search for the issue ID "1234" in descriptions against
all of "issue 1234", "issue:1234", issue1234" and "bug(1234)"
patterns, the revset below should be written fully from scratch for
each issue ID.
grep(r"\bissue[ :]?1234\b|\bbug\(1234\)")
This patch introduces new infix operator "##" to concatenate
strings/symbols at runtime. Operator symbol "##" comes from the same
one of C pre-processor. This concatenation allows parametrizing a part
of strings in revset queries.
In the case of example above, the definition of the revset alias using
operator "##" below can search issue ID "1234" in complicated patterns
by "issue(1234)" simply:
issue($1) = grep(r"\bissue[ :]?" ## $1 ## r"\b|\bbug\(" ## $1 ## r"\)")
"##" operator does:
- concatenate not only strings but also symbols into the string
Exact distinction between strings and symbols seems not to be
convenience, because it is tiresome for users (and
"revset.getstring" treats both similarly)
For example of revset alias "issue()", "issue(1234)" is easier
than "issue('1234')".
- have higher priority than any other prefix, infix and postfix
operators (like as "##" of C pre-processor)
This patch (re-)assigns the priority 20 to "##", and 21 to "(",
because priority 19 is already assigned to "-" as prefix "negate".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 06 Jan 2015 23:46:18 +0900 |
parents | ddbe689af784 |
children | 97811ff79647 |
rev | line source |
---|---|
11382 | 1 Mercurial supports a functional language for selecting a set of |
2 revisions. | |
3 | |
4 The language supports a number of predicates which are joined by infix | |
5 operators. Parenthesis can be used for grouping. | |
6 | |
15962
f7c8d6ee6056
revset: simplify help not about quoting
Matt Mackall <mpm@selenic.com>
parents:
14693
diff
changeset
|
7 Identifiers such as branch names may need quoting with single or |
f7c8d6ee6056
revset: simplify help not about quoting
Matt Mackall <mpm@selenic.com>
parents:
14693
diff
changeset
|
8 double quotes if they contain characters like ``-`` or if they match |
f7c8d6ee6056
revset: simplify help not about quoting
Matt Mackall <mpm@selenic.com>
parents:
14693
diff
changeset
|
9 one of the predefined predicates. |
12408
78a97859b90d
revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents:
11944
diff
changeset
|
10 |
78a97859b90d
revset: support raw string literals
Brodie Rao <brodie@bitheap.org>
parents:
11944
diff
changeset
|
11 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
|
12 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
|
13 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``. |
11382 | 14 |
15 There is a single prefix operator: | |
16 | |
17 ``not x`` | |
18 Changesets not in x. Short form is ``! x``. | |
19 | |
20 These are the supported infix operators: | |
21 | |
22 ``x::y`` | |
23 A DAG range, meaning all changesets that are descendants of x and | |
24 ancestors of y, including x and y themselves. If the first endpoint | |
25 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
|
26 is left out it is equivalent to ``descendants(x)``. |
11382 | 27 |
28 An alternative syntax is ``x..y``. | |
29 | |
30 ``x:y`` | |
31 All changesets with revision numbers between x and y, both | |
32 inclusive. Either endpoint can be left out, they default to 0 and | |
33 tip. | |
34 | |
35 ``x and y`` | |
36 The intersection of changesets in x and y. Short form is ``x & y``. | |
37 | |
38 ``x or y`` | |
39 The union of changesets in x and y. There are two alternative short | |
40 forms: ``x | y`` and ``x + y``. | |
41 | |
42 ``x - y`` | |
43 Changesets in x but not in y. | |
14692
0be6dc3d8083
help/revsets: clean up whitespace between paragraphs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
14098
diff
changeset
|
44 |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
45 ``x^n`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
50 ``x~n`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
51 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
|
52 |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
53 There is a single postfix operator: |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
54 |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
55 ``x^`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
13937
diff
changeset
|
56 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
|
57 |
11382 | 58 |
59 The following predicates are supported: | |
60 | |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12808
diff
changeset
|
61 .. predicatesmarker |
11382 | 62 |
14098
9f5a0acb0056
revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents:
14070
diff
changeset
|
63 New predicates (known as "aliases") can be defined, using any combination of |
9f5a0acb0056
revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents:
14070
diff
changeset
|
64 existing predicates or other aliases. An alias definition looks like:: |
9f5a0acb0056
revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents:
14070
diff
changeset
|
65 |
9f5a0acb0056
revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents:
14070
diff
changeset
|
66 <alias> = <definition> |
9f5a0acb0056
revset aliases
Alexander Solovyov <alexander@solovyov.net>
parents:
14070
diff
changeset
|
67 |
14693
f9c056f48018
help/revsets: revset aliases can be defined on any config file
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
14692
diff
changeset
|
68 in the ``revsetalias`` section of a Mercurial configuration file. Arguments |
f9c056f48018
help/revsets: revset aliases can be defined on any config file
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
14692
diff
changeset
|
69 of the form `$1`, `$2`, etc. are substituted from the alias into the |
f9c056f48018
help/revsets: revset aliases can be defined on any config file
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
14692
diff
changeset
|
70 definition. |
14098
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 |
23742
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
84 An infix operator ``##`` can concatenate strings and identifiers into |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
85 one string. For example:: |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
86 |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
87 [revsetalias] |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
88 issue($1) = grep(r'\bissue[ :]?' ## $1 ## r'\b|\bbug\(' ## $1 ## r'\)') |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
89 |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
90 ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')`` |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
91 in this case. This matches against all of "issue 1234", "issue:1234", |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
92 "issue1234" and "bug(1234)". |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
93 |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
94 All other prefix, infix and postfix operators have lower priority than |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
95 ``##``. For example, ``$1 ## $2~2`` is equivalent to ``($1 ## $2)~2``. |
3a4d8a6ce432
revset: introduce new operator "##" to concatenate strings/symbols at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18469
diff
changeset
|
96 |
11382 | 97 Command line equivalents for :hg:`log`:: |
98 | |
99 -f -> ::. | |
100 -d x -> date(x) | |
101 -k x -> keyword(x) | |
102 -m -> merge() | |
103 -u x -> user(x) | |
104 -b x -> branch(x) | |
105 -P x -> !::x | |
106 -l x -> limit(expr, x) | |
107 | |
12659
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
108 Some sample queries: |
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
109 |
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
110 - Changesets on the default branch:: |
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 "branch(default)" |
12659
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
113 |
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
114 - 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
|
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 "branch(default) and 1.5:: and not merge()" |
11382 | 117 |
12660
6ed5ae6264c2
revsets: add a sample query to the help for getting active branches
Brodie Rao <brodie@bitheap.org>
parents:
12659
diff
changeset
|
118 - 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
|
119 |
12808
74f6531581e8
help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents:
12716
diff
changeset
|
120 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
|
121 |
12659
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
122 - 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
|
123 ``hgext/*``:: |
12659
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
124 |
12808
74f6531581e8
help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents:
12716
diff
changeset
|
125 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
|
126 |
13937
5f126c01ebfa
help/revset: fix grammar
Idan Kamara <idankk86@gmail.com>
parents:
12821
diff
changeset
|
127 - 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
|
128 |
12808
74f6531581e8
help: use Windows cmd compatible quoting in revset help
Mads Kiilerich <mads@kiilerich.com>
parents:
12716
diff
changeset
|
129 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
|
130 |
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
131 - 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
|
132 release:: |
5aa5cbaf6efc
revsets: add descriptions for sample queries in the help
Brodie Rao <brodie@bitheap.org>
parents:
12657
diff
changeset
|
133 |
18469
ddbe689af784
doc: use "tag" revset predicate instead of "tagged" for example in help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15962
diff
changeset
|
134 hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())" |