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