##// END OF EJS Templates
help: add sections for revsets
timeless -
r29989:5271ae66 default
parent child Browse files
Show More
@@ -1,143 +1,162
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 Prefix
16 ======
17
15 There is a single prefix operator:
18 There is a single prefix operator:
16
19
17 ``not x``
20 ``not x``
18 Changesets not in x. Short form is ``! x``.
21 Changesets not in x. Short form is ``! x``.
19
22
23 Infix
24 =====
25
20 These are the supported infix operators:
26 These are the supported infix operators:
21
27
22 ``x::y``
28 ``x::y``
23 A DAG range, meaning all changesets that are descendants of x and
29 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
30 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
31 is left out, this is equivalent to ``ancestors(y)``, if the second
26 is left out it is equivalent to ``descendants(x)``.
32 is left out it is equivalent to ``descendants(x)``.
27
33
28 An alternative syntax is ``x..y``.
34 An alternative syntax is ``x..y``.
29
35
30 ``x:y``
36 ``x:y``
31 All changesets with revision numbers between x and y, both
37 All changesets with revision numbers between x and y, both
32 inclusive. Either endpoint can be left out, they default to 0 and
38 inclusive. Either endpoint can be left out, they default to 0 and
33 tip.
39 tip.
34
40
35 ``x and y``
41 ``x and y``
36 The intersection of changesets in x and y. Short form is ``x & y``.
42 The intersection of changesets in x and y. Short form is ``x & y``.
37
43
38 ``x or y``
44 ``x or y``
39 The union of changesets in x and y. There are two alternative short
45 The union of changesets in x and y. There are two alternative short
40 forms: ``x | y`` and ``x + y``.
46 forms: ``x | y`` and ``x + y``.
41
47
42 ``x - y``
48 ``x - y``
43 Changesets in x but not in y.
49 Changesets in x but not in y.
44
50
45 ``x % y``
51 ``x % y``
46 Changesets that are ancestors of x but not ancestors of y (i.e. ::x - ::y).
52 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
53 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)``.
54 argument is optional and, if left out, is equivalent to ``only(x)``.
49
55
50 ``x^n``
56 ``x^n``
51 The nth parent of x, n == 0, 1, or 2.
57 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;
58 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.
59 for n == 2, the second parent of changeset in x.
54
60
55 ``x~n``
61 ``x~n``
56 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
62 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
57
63
58 ``x ## y``
64 ``x ## y``
59 Concatenate strings and identifiers into one string.
65 Concatenate strings and identifiers into one string.
60
66
61 All other prefix, infix and postfix operators have lower priority than
67 All other prefix, infix and postfix operators have lower priority than
62 ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
68 ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
63
69
64 For example::
70 For example::
65
71
66 [revsetalias]
72 [revsetalias]
67 issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
73 issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
68
74
69 ``issue(1234)`` is equivalent to
75 ``issue(1234)`` is equivalent to
70 ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
76 ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
71 in this case. This matches against all of "issue 1234", "issue:1234",
77 in this case. This matches against all of "issue 1234", "issue:1234",
72 "issue1234" and "bug(1234)".
78 "issue1234" and "bug(1234)".
73
79
80 Postfix
81 =======
82
74 There is a single postfix operator:
83 There is a single postfix operator:
75
84
76 ``x^``
85 ``x^``
77 Equivalent to ``x^1``, the first parent of each changeset in x.
86 Equivalent to ``x^1``, the first parent of each changeset in x.
78
87
88 Predicates
89 ==========
79
90
80 The following predicates are supported:
91 The following predicates are supported:
81
92
82 .. predicatesmarker
93 .. predicatesmarker
83
94
95 Aliases
96 =======
97
84 New predicates (known as "aliases") can be defined, using any combination of
98 New predicates (known as "aliases") can be defined, using any combination of
85 existing predicates or other aliases. An alias definition looks like::
99 existing predicates or other aliases. An alias definition looks like::
86
100
87 <alias> = <definition>
101 <alias> = <definition>
88
102
89 in the ``revsetalias`` section of a Mercurial configuration file. Arguments
103 in the ``revsetalias`` section of a Mercurial configuration file. Arguments
90 of the form `a1`, `a2`, etc. are substituted from the alias into the
104 of the form `a1`, `a2`, etc. are substituted from the alias into the
91 definition.
105 definition.
92
106
93 For example,
107 For example,
94
108
95 ::
109 ::
96
110
97 [revsetalias]
111 [revsetalias]
98 h = heads()
112 h = heads()
99 d(s) = sort(s, date)
113 d(s) = sort(s, date)
100 rs(s, k) = reverse(sort(s, k))
114 rs(s, k) = reverse(sort(s, k))
101
115
102 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
116 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
103 exactly equivalent to ``reverse(sort(0:tip, author))``.
117 exactly equivalent to ``reverse(sort(0:tip, author))``.
104
118
119 Equivalents
120 ===========
105
121
106 Command line equivalents for :hg:`log`::
122 Command line equivalents for :hg:`log`::
107
123
108 -f -> ::.
124 -f -> ::.
109 -d x -> date(x)
125 -d x -> date(x)
110 -k x -> keyword(x)
126 -k x -> keyword(x)
111 -m -> merge()
127 -m -> merge()
112 -u x -> user(x)
128 -u x -> user(x)
113 -b x -> branch(x)
129 -b x -> branch(x)
114 -P x -> !::x
130 -P x -> !::x
115 -l x -> limit(expr, x)
131 -l x -> limit(expr, x)
116
132
133 Examples
134 ========
135
117 Some sample queries:
136 Some sample queries:
118
137
119 - Changesets on the default branch::
138 - Changesets on the default branch::
120
139
121 hg log -r "branch(default)"
140 hg log -r "branch(default)"
122
141
123 - Changesets on the default branch since tag 1.5 (excluding merges)::
142 - Changesets on the default branch since tag 1.5 (excluding merges)::
124
143
125 hg log -r "branch(default) and 1.5:: and not merge()"
144 hg log -r "branch(default) and 1.5:: and not merge()"
126
145
127 - Open branch heads::
146 - Open branch heads::
128
147
129 hg log -r "head() and not closed()"
148 hg log -r "head() and not closed()"
130
149
131 - Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
150 - Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
132 ``hgext/*``::
151 ``hgext/*``::
133
152
134 hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
153 hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
135
154
136 - Changesets committed in May 2008, sorted by user::
155 - Changesets committed in May 2008, sorted by user::
137
156
138 hg log -r "sort(date('May 2008'), user)"
157 hg log -r "sort(date('May 2008'), user)"
139
158
140 - Changesets mentioning "bug" or "issue" that are not in a tagged
159 - Changesets mentioning "bug" or "issue" that are not in a tagged
141 release::
160 release::
142
161
143 hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())"
162 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