annotate mercurial/help/filesets.txt @ 18792:10669e24eb6c

completion: add a debugpathcomplete command The bash_completion code uses "hg status" to generate a list of possible completions for commands that operate on files in the working directory. In a large working directory, this can result in a single tab-completion being very slow (several seconds) as a result of checking the status of every file, even when there is no need to check status or no possible matches. The new debugpathcomplete command gains performance in a few simple ways: * Allow completion to operate on just a single directory. When used to complete the right commands, this considerably reduces the number of completions returned, at no loss in functionality. * Never check the status of files. For completions that really must know if a file is modified, it is faster to use status: hg status -nm 'glob:myprefix**' Performance: Here are the commands used by bash_completion to complete, run in the root of the mozilla-central working dir (~77,000 files) and another repo (~165,000 files): All "normal state" files (used by e.g. remove, revert): mozilla other status -nmcd 'glob:**' 1.77 4.10 sec debugpathcomplete -f -n 0.53 1.26 debugpathcomplete -n 0.17 0.41 ("-f" means "complete full paths", rather than the current directory) Tracked files matching "a": mozilla other status -nmcd 'glob:a**' 0.26 0.47 debugpathcomplete -f -n a 0.10 0.24 debugpathcomplete -n a 0.10 0.22 We should be able to further improve completion performance once the critbit work lands. Right now, our performance is limited by the need to iterate over all keys in the dirstate.
author Bryan O'Sullivan <bryano@fb.com>
date Thu, 21 Mar 2013 16:31:28 -0700
parents 8b611944eb84
children 170fc0949fb6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
1 Mercurial supports a functional language for selecting a set of
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 files.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
3
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 Like other file patterns, this pattern type is indicated by a prefix,
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
5 'set:'. The language supports a number of predicates which are joined
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
6 by infix operators. Parenthesis can be used for grouping.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
8 Identifiers such as filenames or patterns must be quoted with single
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
9 or double quotes if they contain characters outside of
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
10 ``[.*{}[]?/\_a-zA-Z0-9\x80-\xff]`` or if they match one of the
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
11 predefined predicates. This generally applies to file patterns other
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
12 than globs and arguments for predicates.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
13
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
14 Special characters can be used in quoted identifiers by escaping them,
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
15 e.g., ``\n`` is interpreted as a newline. To prevent them from being
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
16 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
17
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
18 There is a single prefix operator:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
19
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
20 ``not x``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
21 Files not in x. Short form is ``! x``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
22
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
23 These are the supported infix operators:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
24
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
25 ``x and y``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
26 The intersection of files in x and y. Short form is ``x & y``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
27
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
28 ``x or y``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
29 The union of files in x and y. There are two alternative short
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
30 forms: ``x | y`` and ``x + y``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
31
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
32 ``x - y``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
33 Files in x but not in y.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
34
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
35 The following predicates are supported:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
36
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
37 .. predicatesmarker
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
38
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
39 Some sample queries:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
40
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
41 - Show status of files that appear to be binary in the working directory::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
42
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
43 hg status -A "set:binary()"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
44
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
45 - Forget files that are in .hgignore but are already tracked::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
46
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
47 hg forget "set:hgignore() and not ignored()"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
48
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
49 - Find text files that contain a string::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
50
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
51 hg locate "set:grep(magic) and not binary()"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
52
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
53 - Find C files in a non-standard encoding::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
54
15825
8b611944eb84 filesets: use example with quotes for encoding predicate
Martin Geisler <mg@aragost.com>
parents: 14829
diff changeset
55 hg locate "set:**.c and not encoding('UTF-8')"
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
56
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
57 - Revert copies of large binary files::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
58
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
59 hg revert "set:copied() and binary() and size('>1M')"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
60
14829
968c301a1005 help: fileset foo.lst was named files.lst
Arne Babenhauserheide <bab@draketo.de>
parents: 14686
diff changeset
61 - Remove files listed in foo.lst that contain the letter a or b::
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
62
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
63 hg remove "set: 'listfile:foo.lst' and (**a* or **b*)"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
64
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
65 See also :hg:`help patterns`.