author | Matt Harbison <matt_harbison@yahoo.com> |
Sun, 08 Jan 2017 02:40:36 -0500 | |
changeset 30729 | a4bc8fff67fc |
parent 23109 | cf56f7a60b45 |
child 30731 | b8a188a6f191 |
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 |
|
12 |
than globs and arguments for predicates. |
|
13 |
||
14 |
Special characters can be used in quoted identifiers by escaping them, |
|
15 |
e.g., ``\n`` is interpreted as a newline. To prevent them from being |
|
16 |
interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``. |
|
17 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
18 |
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
|
19 |
|
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
20 |
Prefix |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
21 |
====== |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
22 |
|
14686 | 23 |
There is a single prefix operator: |
24 |
||
25 |
``not x`` |
|
26 |
Files not in x. Short form is ``! x``. |
|
27 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
28 |
Infix |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
29 |
===== |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
30 |
|
14686 | 31 |
These are the supported infix operators: |
32 |
||
33 |
``x and y`` |
|
34 |
The intersection of files in x and y. Short form is ``x & y``. |
|
35 |
||
36 |
``x or y`` |
|
37 |
The union of files in x and y. There are two alternative short |
|
38 |
forms: ``x | y`` and ``x + y``. |
|
39 |
||
40 |
``x - y`` |
|
41 |
Files in x but not in y. |
|
42 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
43 |
Predicates |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
44 |
========== |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
45 |
|
14686 | 46 |
The following predicates are supported: |
47 |
||
48 |
.. predicatesmarker |
|
49 |
||
30729
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
50 |
Examples |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
51 |
======== |
a4bc8fff67fc
help: apply the section headings from revsets to filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
23109
diff
changeset
|
52 |
|
14686 | 53 |
Some sample queries: |
54 |
||
55 |
- Show status of files that appear to be binary in the working directory:: |
|
56 |
||
57 |
hg status -A "set:binary()" |
|
58 |
||
59 |
- Forget files that are in .hgignore but are already tracked:: |
|
60 |
||
61 |
hg forget "set:hgignore() and not ignored()" |
|
62 |
||
63 |
- Find text files that contain a string:: |
|
64 |
||
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
|
65 |
hg files "set:grep(magic) and not binary()" |
14686 | 66 |
|
67 |
- Find C files in a non-standard encoding:: |
|
68 |
||
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
|
69 |
hg files "set:**.c and not encoding('UTF-8')" |
14686 | 70 |
|
71 |
- Revert copies of large binary files:: |
|
72 |
||
73 |
hg revert "set:copied() and binary() and size('>1M')" |
|
74 |
||
14829
968c301a1005
help: fileset foo.lst was named files.lst
Arne Babenhauserheide <bab@draketo.de>
parents:
14686
diff
changeset
|
75 |
- Remove files listed in foo.lst that contain the letter a or b:: |
14686 | 76 |
|
77 |
hg remove "set: 'listfile:foo.lst' and (**a* or **b*)" |