##// END OF EJS Templates
match: sort patterns before compiling them into a regex...
match: sort patterns before compiling them into a regex While investigating cripping performance for `hg cat` in some context, I discovered that, for large inputs, building a regex from out of order patterns result may result in a *much* slower regex and a much slower associated matcher's performance. So we are now sorting the patterns to help the regex engine. There is more to the story as we rely on regexp more than we should. See the next changeset for details. Benchmarks ========== In the following benchmark we are comparing the `hg cat` and `hg files` run time when matching against the full list of files in the repository. They are run: - without the rust extensions - with the standard python enfine (so without re2) sort vs non-sorted - Before this changeset (3f5137543773) --------------------------------------------------------- ###### hg files ############################################################### ### mercurial-2018-08-01-zstd-sparse-revlog sorted: 0.230092 seconds shuffled: 0.234235 seconds (+1.80%) ### pypy-2018-08-01-zstd-sparse-revlog sorted: 0.613567 seconds shuffled: 0.801880 seconds (+30.69%) ### mozilla-central-2018-08-01-zstd-sparse-revlog sorted: 62.474221 seconds shuffled: 1364.180218 seconds (+2083.59%) ### netbeans-2018-08-01-zstd-sparse-revlog sorted: 21.541828 seconds shuffled: 172.759857 seconds (+701.97%) ###### hg cat ################################################################# ### mercurial-2018-08-01-zstd-sparse-revlog sorted: 0.764407 seconds shuffled: 0.768924 seconds ### pypy-2018-08-01-zstd-sparse-revlog sorted: 2.065220 seconds shuffled: 2.276388 seconds (+10.22%) ### netbeans-2018-08-01-zstd-sparse-revlog sorted: 40.967983 seconds shuffled: 216.388709 seconds (+428.19%) ### mozilla-central-2018-08-01-zstd-sparse-revlog sorted: 105.228510 seconds shuffled: 1448.722784 seconds (+1276.74%) sort vs non-sorted - With this changeset ---------------------------------------- ###### hg files ############################################################### ### mercurial-2018-08-01-zstd-sparse-revlog all-list-pattern-sorted: 0.230069 all-list-pattern-shuffled: 0.231165 ### pypy-2018-08-01-zstd-sparse-revlog all-list-pattern-sorted: 0.616799 all-list-pattern-shuffled: 0.616393 ### netbeans-2018-08-01-zstd-sparse-revlog all-list-pattern-sorted: 21.586773 all-list-pattern-shuffled: 21.908197 ### mozilla-central-2018-08-01-zstd-sparse-revlog all-list-pattern-sorted: 61.279490 all-list-pattern-shuffled: 62.473549 ###### hg cat ################################################################# ### mercurial-2018-08-01-zstd-sparse-revlog sorted: 0.763883 seconds shuffled: 0.765848 seconds ### pypy-2018-08-01-zstd-sparse-revlog sorted: 2.070498 seconds shuffled: 2.069197 seconds ### netbeans-2018-08-01-zstd-sparse-revlog sorted: 41.392423 seconds shuffled: 41.648689 seconds ### mozilla-central-2018-08-01-zstd-sparse-revlog sorted: 103.315670 seconds shuffled: 104.369358 seconds

File last commit:

r44031:2e017696 default
r51285:47686726 stable
Show More
filesets.txt
79 lines | 2.1 KiB | text/plain | TextLexer
Mercurial supports a functional language for selecting a set of
files.
Like other file patterns, this pattern type is indicated by a prefix,
'set:'. The language supports a number of predicates which are joined
by infix operators. Parenthesis can be used for grouping.
Identifiers such as filenames or patterns must be quoted with single
or double quotes if they contain characters outside of
``[.*{}[]?/\_a-zA-Z0-9\x80-\xff]`` or if they match one of the
predefined predicates. This generally applies to file patterns other
than globs and arguments for predicates. Pattern prefixes such as
``path:`` may be specified without quoting.
Special characters can be used in quoted identifiers by escaping them,
e.g., ``\n`` is interpreted as a newline. To prevent them from being
interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
See also :hg:`help patterns`.
Operators
=========
There is a single prefix operator:
``not x``
Files not in x. Short form is ``! x``.
These are the supported infix operators:
``x and y``
The intersection of files in x and y. Short form is ``x & y``.
``x or y``
The union of files in x and y. There are two alternative short
forms: ``x | y`` and ``x + y``.
``x - y``
Files in x but not in y.
Predicates
==========
The following predicates are supported:
.. predicatesmarker
Examples
========
Some sample queries:
- Show status of files that appear to be binary in the working directory::
hg status -A "set:binary()"
- Forget files that are in .hgignore but are already tracked::
hg forget "set:hgignore() and not ignored()"
- Find text files that contain a string::
hg files "set:grep(magic) and not binary()"
- Find C files in a non-standard encoding::
hg files "set:**.c and not encoding('UTF-8')"
- Revert copies of large binary files::
hg revert "set:copied() and binary() and size('>1M')"
- Revert files that were added to the working directory::
hg revert "set:revs('wdir()', added())"
- Remove files listed in foo.lst that contain the letter a or b::
hg remove "set: listfile:foo.lst and (**a* or **b*)"