Mercurial > hg
diff mercurial/helptext/patterns.txt @ 50695:1c31b343e514
match: add `filepath:` pattern to match an exact filepath relative to the root
It's useful in certain automated workflows to make sure we recurse in
directories whose name conflicts with files in other revisions.
In addition it makes it possible to avoid building a potentially costly regex,
improving performance when the set of files to match explicitly is large.
The benchmark below are run in the following configuration :
# data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog
# benchmark.name = files
# benchmark.variants.rev = tip
# benchmark.variants.files = all-list-filepath-sorted
# bin-env-vars.hg.flavor = no-rust
It also includes timings using the re2 engine (through the `google-re2` module)
to show how much can be saved by just using a better regexp engine.
Pattern time (seconds) time using re2
-----------------------------------------------------------
just "." 0.4 0.4
list of "filepath:…" 1.3 1.3
list of "path:…" 25.7 3.9
list of patterns 29.7 10.4
As you can see, Without re2, using "filepath:" instead of "path:" is a huge
win. With re2, it is still about three times faster to not have to build the
regex.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 12 Jun 2023 16:51:08 +0200 |
parents | 823e906d879d |
children |
line wrap: on
line diff
--- a/mercurial/helptext/patterns.txt Sun Jun 18 00:09:39 2023 +0200 +++ b/mercurial/helptext/patterns.txt Mon Jun 12 16:51:08 2023 +0200 @@ -18,7 +18,8 @@ current repository root, and when the path points to a directory, it is matched recursively. To match all files in a directory non-recursively (not including any files in subdirectories), ``rootfilesin:`` can be used, specifying an -absolute path (relative to the repository root). +absolute path (relative to the repository root). To match a single file exactly, +relative to the repository root, you can use ``filepath:``. To use an extended glob, start a name with ``glob:``. Globs are rooted at the current directory; a glob such as ``*.c`` will only match files @@ -50,11 +51,15 @@ Plain examples:: - path:foo/bar a name bar in a directory named foo in the root - of the repository - path:path:name a file or directory named "path:name" - rootfilesin:foo/bar the files in a directory called foo/bar, but not any files - in its subdirectories and not a file bar in directory foo + path:foo/bar a name bar in a directory named foo in the root + of the repository + path:some/path a file or directory named "some/path" + filepath:some/path/to/a/file exactly a single file named + "some/path/to/a/file", relative to the root + of the repository + rootfilesin:foo/bar the files in a directory called foo/bar, but + not any files in its subdirectories and not + a file bar in directory foo Glob examples::