##// END OF EJS Templates
help/revsets: revset aliases can be defined on any config file
Wagner Bruna -
r14693:f9c056f4 stable
parent child Browse files
Show More
@@ -1,121 +1,122
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 must be quoted with single or double
7 Identifiers such as branch names must be quoted with single or double
8 quotes if they contain characters outside of
8 quotes if they contain characters outside of
9 ``[._a-zA-Z0-9\x80-\xff]`` or if they match one of the predefined
9 ``[._a-zA-Z0-9\x80-\xff]`` or if they match one of the predefined
10 predicates.
10 predicates.
11
11
12 Special characters can be used in quoted identifiers by escaping them,
12 Special characters can be used in quoted identifiers by escaping them,
13 e.g., ``\n`` is interpreted as a newline. To prevent them from being
13 e.g., ``\n`` is interpreted as a newline. To prevent them from being
14 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
14 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
15
15
16 There is a single prefix operator:
16 There is a single prefix operator:
17
17
18 ``not x``
18 ``not x``
19 Changesets not in x. Short form is ``! x``.
19 Changesets not in x. Short form is ``! x``.
20
20
21 These are the supported infix operators:
21 These are the supported infix operators:
22
22
23 ``x::y``
23 ``x::y``
24 A DAG range, meaning all changesets that are descendants of x and
24 A DAG range, meaning all changesets that are descendants of x and
25 ancestors of y, including x and y themselves. If the first endpoint
25 ancestors of y, including x and y themselves. If the first endpoint
26 is left out, this is equivalent to ``ancestors(y)``, if the second
26 is left out, this is equivalent to ``ancestors(y)``, if the second
27 is left out it is equivalent to ``descendants(x)``.
27 is left out it is equivalent to ``descendants(x)``.
28
28
29 An alternative syntax is ``x..y``.
29 An alternative syntax is ``x..y``.
30
30
31 ``x:y``
31 ``x:y``
32 All changesets with revision numbers between x and y, both
32 All changesets with revision numbers between x and y, both
33 inclusive. Either endpoint can be left out, they default to 0 and
33 inclusive. Either endpoint can be left out, they default to 0 and
34 tip.
34 tip.
35
35
36 ``x and y``
36 ``x and y``
37 The intersection of changesets in x and y. Short form is ``x & y``.
37 The intersection of changesets in x and y. Short form is ``x & y``.
38
38
39 ``x or y``
39 ``x or y``
40 The union of changesets in x and y. There are two alternative short
40 The union of changesets in x and y. There are two alternative short
41 forms: ``x | y`` and ``x + y``.
41 forms: ``x | y`` and ``x + y``.
42
42
43 ``x - y``
43 ``x - y``
44 Changesets in x but not in y.
44 Changesets in x but not in y.
45
45
46 ``x^n``
46 ``x^n``
47 The nth parent of x, n == 0, 1, or 2.
47 The nth parent of x, n == 0, 1, or 2.
48 For n == 0, x; for n == 1, the first parent of each changeset in x;
48 For n == 0, x; for n == 1, the first parent of each changeset in x;
49 for n == 2, the second parent of changeset in x.
49 for n == 2, the second parent of changeset in x.
50
50
51 ``x~n``
51 ``x~n``
52 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
52 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
53
53
54 There is a single postfix operator:
54 There is a single postfix operator:
55
55
56 ``x^``
56 ``x^``
57 Equivalent to ``x^1``, the first parent of each changeset in x.
57 Equivalent to ``x^1``, the first parent of each changeset in x.
58
58
59
59
60 The following predicates are supported:
60 The following predicates are supported:
61
61
62 .. predicatesmarker
62 .. predicatesmarker
63
63
64 New predicates (known as "aliases") can be defined, using any combination of
64 New predicates (known as "aliases") can be defined, using any combination of
65 existing predicates or other aliases. An alias definition looks like::
65 existing predicates or other aliases. An alias definition looks like::
66
66
67 <alias> = <definition>
67 <alias> = <definition>
68
68
69 in the ``revsetalias`` section of ``.hgrc``. Arguments of the form `$1`, `$2`,
69 in the ``revsetalias`` section of a Mercurial configuration file. Arguments
70 etc. are substituted from the alias into the definition.
70 of the form `$1`, `$2`, etc. are substituted from the alias into the
71 definition.
71
72
72 For example,
73 For example,
73
74
74 ::
75 ::
75
76
76 [revsetalias]
77 [revsetalias]
77 h = heads()
78 h = heads()
78 d($1) = sort($1, date)
79 d($1) = sort($1, date)
79 rs($1, $2) = reverse(sort($1, $2))
80 rs($1, $2) = reverse(sort($1, $2))
80
81
81 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
82 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
82 exactly equivalent to ``reverse(sort(0:tip, author))``.
83 exactly equivalent to ``reverse(sort(0:tip, author))``.
83
84
84 Command line equivalents for :hg:`log`::
85 Command line equivalents for :hg:`log`::
85
86
86 -f -> ::.
87 -f -> ::.
87 -d x -> date(x)
88 -d x -> date(x)
88 -k x -> keyword(x)
89 -k x -> keyword(x)
89 -m -> merge()
90 -m -> merge()
90 -u x -> user(x)
91 -u x -> user(x)
91 -b x -> branch(x)
92 -b x -> branch(x)
92 -P x -> !::x
93 -P x -> !::x
93 -l x -> limit(expr, x)
94 -l x -> limit(expr, x)
94
95
95 Some sample queries:
96 Some sample queries:
96
97
97 - Changesets on the default branch::
98 - Changesets on the default branch::
98
99
99 hg log -r "branch(default)"
100 hg log -r "branch(default)"
100
101
101 - Changesets on the default branch since tag 1.5 (excluding merges)::
102 - Changesets on the default branch since tag 1.5 (excluding merges)::
102
103
103 hg log -r "branch(default) and 1.5:: and not merge()"
104 hg log -r "branch(default) and 1.5:: and not merge()"
104
105
105 - Open branch heads::
106 - Open branch heads::
106
107
107 hg log -r "head() and not closed()"
108 hg log -r "head() and not closed()"
108
109
109 - Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
110 - Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
110 ``hgext/*``::
111 ``hgext/*``::
111
112
112 hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
113 hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
113
114
114 - Changesets committed in May 2008, sorted by user::
115 - Changesets committed in May 2008, sorted by user::
115
116
116 hg log -r "sort(date('May 2008'), user)"
117 hg log -r "sort(date('May 2008'), user)"
117
118
118 - Changesets mentioning "bug" or "issue" that are not in a tagged
119 - Changesets mentioning "bug" or "issue" that are not in a tagged
119 release::
120 release::
120
121
121 hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tagged())"
122 hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tagged())"
General Comments 0
You need to be logged in to leave comments. Login now