| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 |
<meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" /> |
| 7 |
<title>File Name Patterns</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="file-name-patterns"> |
| 12 |
<span id="topic-patterns"></span> |
| 13 |
<h1 class="title">File Name Patterns</h1> |
| 14 |
|
| 15 |
<p id="patterns">Mercurial accepts several notations for identifying one or more files |
| 16 |
at a time.</p> |
| 17 |
<p>By default, Mercurial treats filenames verbatim without pattern |
| 18 |
matching, relative to the current working directory. Note that your |
| 19 |
system shell might perform pattern matching of its own before passing |
| 20 |
filenames into Mercurial.</p> |
| 21 |
<p>Alternate pattern notations must be specified explicitly.</p> |
| 22 |
<div class="admonition note"> |
| 23 |
<p class="first admonition-title">Note</p> |
| 24 |
<p class="last">Patterns specified in <tt class="docutils literal">.hgignore</tt> are not rooted. |
| 25 |
Please see <a class="reference external" href="topic-hgignore.html"><tt class="docutils literal">hg help hgignore</tt></a> for details.</p> |
| 26 |
</div> |
| 27 |
<p>To use a plain path name without any pattern matching, start it with |
| 28 |
<tt class="docutils literal">path:</tt>. These path names must completely match starting at the |
| 29 |
current repository root, and when the path points to a directory, it is matched |
| 30 |
recursively. To match all files in a directory non-recursively (not including |
| 31 |
any files in subdirectories), <tt class="docutils literal">rootfilesin:</tt> can be used, specifying an |
| 32 |
absolute path (relative to the repository root). To match a single file exactly, |
| 33 |
relative to the repository root, you can use <tt class="docutils literal">filepath:</tt>.</p> |
| 34 |
<p>To use an extended glob, start a name with <tt class="docutils literal">glob:</tt>. Globs are rooted |
| 35 |
at the current directory; a glob such as <tt class="docutils literal">*.c</tt> will only match files |
| 36 |
in the current directory ending with <tt class="docutils literal">.c</tt>. <tt class="docutils literal">rootglob:</tt> can be used |
| 37 |
instead of <tt class="docutils literal">glob:</tt> for a glob that is rooted at the root of the |
| 38 |
repository.</p> |
| 39 |
<p>The supported glob syntax extensions are <tt class="docutils literal">**</tt> to match any string |
| 40 |
across path separators and <tt class="docutils literal">{a,b}</tt> to mean "a or b".</p> |
| 41 |
<p>To use a Perl/Python regular expression, start a name with <tt class="docutils literal">re:</tt>. |
| 42 |
Regexp pattern matching is anchored at the root of the repository.</p> |
| 43 |
<p>To read name patterns from a file, use <tt class="docutils literal">listfile:</tt> or <tt class="docutils literal">listfile0:</tt>. |
| 44 |
The latter expects null delimited patterns while the former expects line |
| 45 |
feeds. Each string read from the file is itself treated as a file |
| 46 |
pattern.</p> |
| 47 |
<p>To read a set of patterns from a file, use <tt class="docutils literal">include:</tt> or <tt class="docutils literal">subinclude:</tt>. |
| 48 |
<tt class="docutils literal">include:</tt> will use all the patterns from the given file and treat them as if |
| 49 |
they had been passed in manually. <tt class="docutils literal">subinclude:</tt> will only apply the patterns |
| 50 |
against files that are under the subinclude file's directory. See <a class="reference external" href="topic-hgignore.html"><tt class="docutils literal">hg help |
| 51 |
hgignore</tt></a> for details on the format of these files.</p> |
| 52 |
<p>All patterns, except for <tt class="docutils literal">glob:</tt> specified in command line (not for |
| 53 |
<tt class="docutils literal"><span class="pre">-I</span></tt> or <tt class="docutils literal"><span class="pre">-X</span></tt> options), can match also against directories: files |
| 54 |
under matched directories are treated as matched. |
| 55 |
For <tt class="docutils literal"><span class="pre">-I</span></tt> and <tt class="docutils literal"><span class="pre">-X</span></tt> options, <tt class="docutils literal">glob:</tt> will match directories recursively.</p> |
| 56 |
<p>Plain examples:</p> |
| 57 |
<pre class="literal-block"> |
| 58 |
path:foo/bar a name bar in a directory named foo in the root |
| 59 |
of the repository |
| 60 |
path:some/path a file or directory named "some/path" |
| 61 |
filepath:some/path/to/a/file exactly a single file named |
| 62 |
"some/path/to/a/file", relative to the root |
| 63 |
of the repository |
| 64 |
rootfilesin:foo/bar the files in a directory called foo/bar, but |
| 65 |
not any files in its subdirectories and not |
| 66 |
a file bar in directory foo |
| 67 |
</pre> |
| 68 |
<p>Glob examples:</p> |
| 69 |
<pre class="literal-block"> |
| 70 |
glob:*.c any name ending in ".c" in the current directory |
| 71 |
*.c any name ending in ".c" in the current directory |
| 72 |
**.c any name ending in ".c" in any subdirectory of the |
| 73 |
current directory including itself. |
| 74 |
foo/* any file in directory foo |
| 75 |
foo/** any file in directory foo plus all its subdirectories, |
| 76 |
recursively |
| 77 |
foo/*.c any name ending in ".c" in the directory foo |
| 78 |
foo/**.c any name ending in ".c" in any subdirectory of foo |
| 79 |
including itself. |
| 80 |
rootglob:*.c any name ending in ".c" in the root of the repository |
| 81 |
</pre> |
| 82 |
<p>Regexp examples:</p> |
| 83 |
<pre class="literal-block"> |
| 84 |
re:.*\.c$ any name ending in ".c", anywhere in the repository |
| 85 |
</pre> |
| 86 |
<p>File examples:</p> |
| 87 |
<pre class="literal-block"> |
| 88 |
listfile:list.txt read list from list.txt with one file pattern per line |
| 89 |
listfile0:list.txt read list from list.txt with null byte delimiters |
| 90 |
</pre> |
| 91 |
<p>See also <a class="reference external" href="topic-filesets.html"><tt class="docutils literal">hg help filesets</tt></a>.</p> |
| 92 |
<p>Include examples:</p> |
| 93 |
<pre class="literal-block"> |
| 94 |
include:path/to/mypatternfile reads patterns to be applied to all paths |
| 95 |
subinclude:path/to/subignorefile reads patterns specifically for paths in the |
| 96 |
subdirectory |
| 97 |
</pre> |
| 98 |
</div> |
| 99 |
</body> |
| 100 |
</html> |