##// END OF EJS Templates
help: move revsets.## documentation into infix section
timeless -
r29988:96358865 default
parent child Browse files
Show More
@@ -1,139 +1,143 b''
1 Mercurial supports a functional language for selecting a set of
1 Mercurial supports a functional language for selecting a set of
2 revisions.
2 revisions.
3
3
4 The language supports a number of predicates which are joined by infix
4 The language supports a number of predicates which are joined by infix
5 operators. Parenthesis can be used for grouping.
5 operators. Parenthesis can be used for grouping.
6
6
7 Identifiers such as branch names may need quoting with single or
7 Identifiers such as branch names may need quoting with single or
8 double quotes if they contain characters like ``-`` or if they match
8 double quotes if they contain characters like ``-`` or if they match
9 one of the predefined predicates.
9 one of the predefined predicates.
10
10
11 Special characters can be used in quoted identifiers by escaping them,
11 Special characters can be used in quoted identifiers by escaping them,
12 e.g., ``\n`` is interpreted as a newline. To prevent them from being
12 e.g., ``\n`` is interpreted as a newline. To prevent them from being
13 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
13 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
14
14
15 There is a single prefix operator:
15 There is a single prefix operator:
16
16
17 ``not x``
17 ``not x``
18 Changesets not in x. Short form is ``! x``.
18 Changesets not in x. Short form is ``! x``.
19
19
20 These are the supported infix operators:
20 These are the supported infix operators:
21
21
22 ``x::y``
22 ``x::y``
23 A DAG range, meaning all changesets that are descendants of x and
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
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
25 is left out, this is equivalent to ``ancestors(y)``, if the second
26 is left out it is equivalent to ``descendants(x)``.
26 is left out it is equivalent to ``descendants(x)``.
27
27
28 An alternative syntax is ``x..y``.
28 An alternative syntax is ``x..y``.
29
29
30 ``x:y``
30 ``x:y``
31 All changesets with revision numbers between x and y, both
31 All changesets with revision numbers between x and y, both
32 inclusive. Either endpoint can be left out, they default to 0 and
32 inclusive. Either endpoint can be left out, they default to 0 and
33 tip.
33 tip.
34
34
35 ``x and y``
35 ``x and y``
36 The intersection of changesets in x and y. Short form is ``x & y``.
36 The intersection of changesets in x and y. Short form is ``x & y``.
37
37
38 ``x or y``
38 ``x or y``
39 The union of changesets in x and y. There are two alternative short
39 The union of changesets in x and y. There are two alternative short
40 forms: ``x | y`` and ``x + y``.
40 forms: ``x | y`` and ``x + y``.
41
41
42 ``x - y``
42 ``x - y``
43 Changesets in x but not in y.
43 Changesets in x but not in y.
44
44
45 ``x % y``
45 ``x % y``
46 Changesets that are ancestors of x but not ancestors of y (i.e. ::x - ::y).
46 Changesets that are ancestors of x but not ancestors of y (i.e. ::x - ::y).
47 This is shorthand notation for ``only(x, y)`` (see below). The second
47 This is shorthand notation for ``only(x, y)`` (see below). The second
48 argument is optional and, if left out, is equivalent to ``only(x)``.
48 argument is optional and, if left out, is equivalent to ``only(x)``.
49
49
50 ``x^n``
50 ``x^n``
51 The nth parent of x, n == 0, 1, or 2.
51 The nth parent of x, n == 0, 1, or 2.
52 For n == 0, x; for n == 1, the first parent of each changeset in x;
52 For n == 0, x; for n == 1, the first parent of each changeset in x;
53 for n == 2, the second parent of changeset in x.
53 for n == 2, the second parent of changeset in x.
54
54
55 ``x~n``
55 ``x~n``
56 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
56 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
57
57
58 ``x ## y``
59 Concatenate strings and identifiers into one string.
60
61 All other prefix, infix and postfix operators have lower priority than
62 ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
63
64 For example::
65
66 [revsetalias]
67 issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
68
69 ``issue(1234)`` is equivalent to
70 ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
71 in this case. This matches against all of "issue 1234", "issue:1234",
72 "issue1234" and "bug(1234)".
73
58 There is a single postfix operator:
74 There is a single postfix operator:
59
75
60 ``x^``
76 ``x^``
61 Equivalent to ``x^1``, the first parent of each changeset in x.
77 Equivalent to ``x^1``, the first parent of each changeset in x.
62
78
63
79
64 The following predicates are supported:
80 The following predicates are supported:
65
81
66 .. predicatesmarker
82 .. predicatesmarker
67
83
68 New predicates (known as "aliases") can be defined, using any combination of
84 New predicates (known as "aliases") can be defined, using any combination of
69 existing predicates or other aliases. An alias definition looks like::
85 existing predicates or other aliases. An alias definition looks like::
70
86
71 <alias> = <definition>
87 <alias> = <definition>
72
88
73 in the ``revsetalias`` section of a Mercurial configuration file. Arguments
89 in the ``revsetalias`` section of a Mercurial configuration file. Arguments
74 of the form `a1`, `a2`, etc. are substituted from the alias into the
90 of the form `a1`, `a2`, etc. are substituted from the alias into the
75 definition.
91 definition.
76
92
77 For example,
93 For example,
78
94
79 ::
95 ::
80
96
81 [revsetalias]
97 [revsetalias]
82 h = heads()
98 h = heads()
83 d(s) = sort(s, date)
99 d(s) = sort(s, date)
84 rs(s, k) = reverse(sort(s, k))
100 rs(s, k) = reverse(sort(s, k))
85
101
86 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
102 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
87 exactly equivalent to ``reverse(sort(0:tip, author))``.
103 exactly equivalent to ``reverse(sort(0:tip, author))``.
88
104
89 An infix operator ``##`` can concatenate strings and identifiers into
90 one string. For example::
91
92 [revsetalias]
93 issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
94
95 ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
96 in this case. This matches against all of "issue 1234", "issue:1234",
97 "issue1234" and "bug(1234)".
98
99 All other prefix, infix and postfix operators have lower priority than
100 ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
101
105
102 Command line equivalents for :hg:`log`::
106 Command line equivalents for :hg:`log`::
103
107
104 -f -> ::.
108 -f -> ::.
105 -d x -> date(x)
109 -d x -> date(x)
106 -k x -> keyword(x)
110 -k x -> keyword(x)
107 -m -> merge()
111 -m -> merge()
108 -u x -> user(x)
112 -u x -> user(x)
109 -b x -> branch(x)
113 -b x -> branch(x)
110 -P x -> !::x
114 -P x -> !::x
111 -l x -> limit(expr, x)
115 -l x -> limit(expr, x)
112
116
113 Some sample queries:
117 Some sample queries:
114
118
115 - Changesets on the default branch::
119 - Changesets on the default branch::
116
120
117 hg log -r "branch(default)"
121 hg log -r "branch(default)"
118
122
119 - Changesets on the default branch since tag 1.5 (excluding merges)::
123 - Changesets on the default branch since tag 1.5 (excluding merges)::
120
124
121 hg log -r "branch(default) and 1.5:: and not merge()"
125 hg log -r "branch(default) and 1.5:: and not merge()"
122
126
123 - Open branch heads::
127 - Open branch heads::
124
128
125 hg log -r "head() and not closed()"
129 hg log -r "head() and not closed()"
126
130
127 - Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
131 - Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
128 ``hgext/*``::
132 ``hgext/*``::
129
133
130 hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
134 hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
131
135
132 - Changesets committed in May 2008, sorted by user::
136 - Changesets committed in May 2008, sorted by user::
133
137
134 hg log -r "sort(date('May 2008'), user)"
138 hg log -r "sort(date('May 2008'), user)"
135
139
136 - Changesets mentioning "bug" or "issue" that are not in a tagged
140 - Changesets mentioning "bug" or "issue" that are not in a tagged
137 release::
141 release::
138
142
139 hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())"
143 hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())"
General Comments 0
You need to be logged in to leave comments. Login now