author | Matt Harbison <matt_harbison@yahoo.com> |
Wed, 09 Jan 2019 16:02:05 -0500 | |
changeset 41180 | 69804c040a04 |
parent 35741 | 73432eee0ac4 |
permissions | -rw-r--r-- |
14686 | 1 |
Mercurial supports a functional language for selecting a set of |
18960
170fc0949fb6
check-code: check txt files for trailing whitespace
Mads Kiilerich <madski@unity3d.com>
parents:
15825
diff
changeset
|
2 |
files. |
14686 | 3 |
|
4 |
Like other file patterns, this pattern type is indicated by a prefix, |
|
5 |
'set:'. The language supports a number of predicates which are joined |
|
6 |
by infix operators. Parenthesis can be used for grouping. |
|
7 |
||
8 |
Identifiers such as filenames or patterns must be quoted with single |
|
9 |
or double quotes if they contain characters outside of |
|
10 |
``[.*{}[]?/\_a-zA-Z0-9\x80-\xff]`` or if they match one of the |
|
11 |
predefined predicates. This generally applies to file patterns other |
|
35741
73432eee0ac4
fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents:
31286
diff
changeset
|
12 |
than globs and arguments for predicates. Pattern prefixes such as |
73432eee0ac4
fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents:
31286
diff
changeset
|
13 |
``path:`` may be specified without quoting. |
14686 | 14 |
|
15 |
Special characters can be used in quoted identifiers by escaping them, |
|
16 |
e.g., ``\n`` is interpreted as a newline. To prevent them from being |
|
17 |
interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``. |
|
18 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
19 |
See also :hg:`help patterns`. |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
20 |
|
30731
b8a188a6f191
help: merge the various operator sections of revsets, filesets and templates
Matt Harbison <matt_harbison@yahoo.com>
parents:
30729
diff
changeset
|
21 |
Operators |
b8a188a6f191
help: merge the various operator sections of revsets, filesets and templates
Matt Harbison <matt_harbison@yahoo.com>
parents:
30729
diff
changeset
|
22 |
========= |
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
23 |
|
14686 | 24 |
There is a single prefix operator: |
25 |
||
26 |
``not x`` |
|
27 |
Files not in x. Short form is ``! x``. |
|
28 |
||
29 |
These are the supported infix operators: |
|
30 |
||
31 |
``x and y`` |
|
32 |
The intersection of files in x and y. Short form is ``x & y``. |
|
33 |
||
34 |
``x or y`` |
|
35 |
The union of files in x and y. There are two alternative short |
|
36 |
forms: ``x | y`` and ``x + y``. |
|
37 |
||
38 |
``x - y`` |
|
39 |
Files in x but not in y. |
|
40 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
41 |
Predicates |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
42 |
========== |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
43 |
|
14686 | 44 |
The following predicates are supported: |
45 |
||
46 |
.. predicatesmarker |
|
47 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
48 |
Examples |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
49 |
======== |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
50 |
|
14686 | 51 |
Some sample queries: |
52 |
||
53 |
- Show status of files that appear to be binary in the working directory:: |
|
54 |
||
55 |
hg status -A "set:binary()" |
|
56 |
||
57 |
- Forget files that are in .hgignore but are already tracked:: |
|
58 |
||
59 |
hg forget "set:hgignore() and not ignored()" |
|
60 |
||
61 |
- Find text files that contain a string:: |
|
62 |
||
23109
cf56f7a60b45
help: use "hg files" instead of "hg locate" in "hg help filesets"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18960
diff
changeset
|
63 |
hg files "set:grep(magic) and not binary()" |
14686 | 64 |
|
65 |
- Find C files in a non-standard encoding:: |
|
66 |
||
23109
cf56f7a60b45
help: use "hg files" instead of "hg locate" in "hg help filesets"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18960
diff
changeset
|
67 |
hg files "set:**.c and not encoding('UTF-8')" |
14686 | 68 |
|
69 |
- Revert copies of large binary files:: |
|
70 |
||
71 |
hg revert "set:copied() and binary() and size('>1M')" |
|
72 |
||
31193
4140d49d2efb
fileset: add revs(revs, fileset) to evaluate set in working directory
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30731
diff
changeset
|
73 |
- Revert files that were added to the working directory:: |
4140d49d2efb
fileset: add revs(revs, fileset) to evaluate set in working directory
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30731
diff
changeset
|
74 |
|
31286
f8df87018ae9
help: fix example of revs() fileset
Yuya Nishihara <yuya@tcha.org>
parents:
31193
diff
changeset
|
75 |
hg revert "set:revs('wdir()', added())" |
31193
4140d49d2efb
fileset: add revs(revs, fileset) to evaluate set in working directory
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30731
diff
changeset
|
76 |
|
14829
968c301a1005
help: fileset foo.lst was named files.lst
Arne Babenhauserheide <bab@draketo.de>
parents:
14686
diff
changeset
|
77 |
- Remove files listed in foo.lst that contain the letter a or b:: |
14686 | 78 |
|
35741
73432eee0ac4
fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents:
31286
diff
changeset
|
79 |
hg remove "set: listfile:foo.lst and (**a* or **b*)" |