Mercurial > hg
comparison mercurial/help/revsets.txt @ 28986:97811ff79647 stable
help: avoid using "$n" parameter in revsetalias example
Because parsing "$n" requires a crafted tokenizer, it exists only for backward
compatibility (as documented in revset._tokenizealias.) This patch updates the
examples so that users are encouraged to use symbolic names instead of "$n"s.
I'm going to implement alias expansion in templater, which won't support "$n"
parameters to make my life easier. Templater is more complicated than revset
because tokenizer and parser call each other.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Mar 2016 18:50:56 +0900 |
parents | 3a4d8a6ce432 |
children | 18c1b107898e |
comparison
equal
deleted
inserted
replaced
28985:d2b29c848fcd | 28986:97811ff79647 |
---|---|
64 existing predicates or other aliases. An alias definition looks like:: | 64 existing predicates or other aliases. An alias definition looks like:: |
65 | 65 |
66 <alias> = <definition> | 66 <alias> = <definition> |
67 | 67 |
68 in the ``revsetalias`` section of a Mercurial configuration file. Arguments | 68 in the ``revsetalias`` section of a Mercurial configuration file. Arguments |
69 of the form `$1`, `$2`, etc. are substituted from the alias into the | 69 of the form `a1`, `a2`, etc. are substituted from the alias into the |
70 definition. | 70 definition. |
71 | 71 |
72 For example, | 72 For example, |
73 | 73 |
74 :: | 74 :: |
75 | 75 |
76 [revsetalias] | 76 [revsetalias] |
77 h = heads() | 77 h = heads() |
78 d($1) = sort($1, date) | 78 d(s) = sort(s, date) |
79 rs($1, $2) = reverse(sort($1, $2)) | 79 rs(s, k) = reverse(sort(s, k)) |
80 | 80 |
81 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is | 81 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is |
82 exactly equivalent to ``reverse(sort(0:tip, author))``. | 82 exactly equivalent to ``reverse(sort(0:tip, author))``. |
83 | 83 |
84 An infix operator ``##`` can concatenate strings and identifiers into | 84 An infix operator ``##`` can concatenate strings and identifiers into |
85 one string. For example:: | 85 one string. For example:: |
86 | 86 |
87 [revsetalias] | 87 [revsetalias] |
88 issue($1) = grep(r'\bissue[ :]?' ## $1 ## r'\b|\bbug\(' ## $1 ## r'\)') | 88 issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)') |
89 | 89 |
90 ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')`` | 90 ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')`` |
91 in this case. This matches against all of "issue 1234", "issue:1234", | 91 in this case. This matches against all of "issue 1234", "issue:1234", |
92 "issue1234" and "bug(1234)". | 92 "issue1234" and "bug(1234)". |
93 | 93 |
94 All other prefix, infix and postfix operators have lower priority than | 94 All other prefix, infix and postfix operators have lower priority than |
95 ``##``. For example, ``$1 ## $2~2`` is equivalent to ``($1 ## $2)~2``. | 95 ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``. |
96 | 96 |
97 Command line equivalents for :hg:`log`:: | 97 Command line equivalents for :hg:`log`:: |
98 | 98 |
99 -f -> ::. | 99 -f -> ::. |
100 -d x -> date(x) | 100 -d x -> date(x) |