Debian Codegraph @

doc/html/topic-filesets.html

raw
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>Specifying File Sets</title>
8 <link rel="stylesheet" href="../style.css" type="text/css" />
9 </head>
10 <body>
11 <div class="document" id="specifying-file-sets">
12 <span id="topic-filesets"></span>
13 <h1 class="title">Specifying File Sets</h1>
14
15 <div class="contents htmlonly topic" id="contents">
16 <p class="topic-title"><a class="reference internal" href="#top">Contents</a></p>
17 <ul class="simple">
18 <li><a class="reference internal" href="#operators" id="toc-entry-1">Operators</a></li>
19 <li><a class="reference internal" href="#predicates" id="toc-entry-2">Predicates</a></li>
20 <li><a class="reference internal" href="#examples" id="toc-entry-3">Examples</a></li>
21 </ul>
22 </div>
23 <p id="fileset"><span id="filesets"></span>Mercurial supports a functional language for selecting a set of
24 files.</p>
25 <p>Like other file patterns, this pattern type is indicated by a prefix,
26 'set:'. The language supports a number of predicates which are joined
27 by infix operators. Parenthesis can be used for grouping.</p>
28 <p>Identifiers such as filenames or patterns must be quoted with single
29 or double quotes if they contain characters outside of
30 <tt class="docutils literal"><span class="pre">[.*{}[]?/\_a-zA-Z0-9\x80-\xff]</span></tt> or if they match one of the
31 predefined predicates. This generally applies to file patterns other
32 than globs and arguments for predicates. Pattern prefixes such as
33 <tt class="docutils literal">path:</tt> may be specified without quoting.</p>
34 <p>Special characters can be used in quoted identifiers by escaping them,
35 e.g., <tt class="docutils literal">\n</tt> is interpreted as a newline. To prevent them from being
36 interpreted, strings can be prefixed with <tt class="docutils literal">r</tt>, e.g. <tt class="docutils literal"><span class="pre">r'...'</span></tt>.</p>
37 <p>See also <a class="reference external" href="topic-patterns.html"><tt class="docutils literal">hg help patterns</tt></a>.</p>
38 <div class="section" id="operators">
39 <h1><a class="toc-backref" href="#contents">Operators</a></h1>
40 <p>There is a single prefix operator:</p>
41 <dl class="docutils">
42 <dt><tt class="docutils literal">not x</tt></dt>
43 <dd>Files not in x. Short form is <tt class="docutils literal">! x</tt>.</dd>
44 </dl>
45 <p>These are the supported infix operators:</p>
46 <dl class="docutils">
47 <dt><tt class="docutils literal">x and y</tt></dt>
48 <dd>The intersection of files in x and y. Short form is <tt class="docutils literal">x &amp; y</tt>.</dd>
49 <dt><tt class="docutils literal">x or y</tt></dt>
50 <dd>The union of files in x and y. There are two alternative short
51 forms: <tt class="docutils literal">x | y</tt> and <tt class="docutils literal">x + y</tt>.</dd>
52 <dt><tt class="docutils literal">x - y</tt></dt>
53 <dd>Files in x but not in y.</dd>
54 </dl>
55 </div>
56 <div class="section" id="predicates">
57 <h1><a class="toc-backref" href="#contents">Predicates</a></h1>
58 <p>The following predicates are supported:</p>
59 <dl class="docutils">
60 <dt><tt class="docutils literal">added()</tt></dt>
61 <dd>File that is added according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
62 <dt><tt class="docutils literal">binary()</tt></dt>
63 <dd>File that appears to be binary (contains NUL bytes).</dd>
64 <dt><tt class="docutils literal">clean()</tt></dt>
65 <dd>File that is clean according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
66 <dt><tt class="docutils literal">copied()</tt></dt>
67 <dd>File that is recorded as being copied.</dd>
68 <dt><tt class="docutils literal">deleted()</tt></dt>
69 <dd>Alias for <tt class="docutils literal">missing()</tt>.</dd>
70 <dt><tt class="docutils literal">encoding(name)</tt></dt>
71 <dd>File can be successfully decoded with the given character
72 encoding. May not be useful for encodings other than ASCII and
73 UTF-8.</dd>
74 <dt><tt class="docutils literal">eol(style)</tt></dt>
75 <dd>File contains newlines of the given style (dos, unix, mac). Binary
76 files are excluded, files with mixed line endings match multiple
77 styles.</dd>
78 <dt><tt class="docutils literal">exec()</tt></dt>
79 <dd>File that is marked as executable.</dd>
80 <dt><tt class="docutils literal">grep(regex)</tt></dt>
81 <dd>File contains the given regular expression.</dd>
82 <dt><tt class="docutils literal">hgignore()</tt></dt>
83 <dd>File that matches the active .hgignore pattern.</dd>
84 <dt><tt class="docutils literal">ignored()</tt></dt>
85 <dd>File that is ignored according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
86 <dt><tt class="docutils literal">missing()</tt></dt>
87 <dd>File that is missing according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
88 <dt><tt class="docutils literal">modified()</tt></dt>
89 <dd>File that is modified according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
90 <dt><tt class="docutils literal">portable()</tt></dt>
91 <dd>File that has a portable name. (This doesn't include filenames with case
92 collisions.)</dd>
93 <dt><tt class="docutils literal">removed()</tt></dt>
94 <dd>File that is removed according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
95 <dt><tt class="docutils literal">resolved()</tt></dt>
96 <dd>File that is marked resolved according to <a class="reference external" href="hg-resolve.html"><tt class="docutils literal">hg resolve <span class="pre">-l</span></tt></a>.</dd>
97 <dt><tt class="docutils literal">revs(revs, pattern)</tt></dt>
98 <dd>Evaluate set in the specified revisions. If the revset match multiple
99 revs, this will return file matching pattern in any of the revision.</dd>
100 <dt><tt class="docutils literal">size(expression)</tt></dt>
101 <dd><p class="first">File size matches the given expression. Examples:</p>
102 <ul class="last simple">
103 <li>size('1k') - files from 1024 to 2047 bytes</li>
104 <li>size('&lt; 20k') - files less than 20480 bytes</li>
105 <li>size('&gt;= .5MB') - files at least 524288 bytes</li>
106 <li>size('4k - 1MB') - files from 4096 bytes to 1048576 bytes</li>
107 </ul>
108 </dd>
109 <dt><tt class="docutils literal">status(base, rev, pattern)</tt></dt>
110 <dd><p class="first">Evaluate predicate using status change between <tt class="docutils literal">base</tt> and
111 <tt class="docutils literal">rev</tt>. Examples:</p>
112 <ul class="last simple">
113 <li><tt class="docutils literal">status(3, 7, <span class="pre">added())</span></tt> - matches files added from &quot;3&quot; to &quot;7&quot;</li>
114 </ul>
115 </dd>
116 <dt><tt class="docutils literal"><span class="pre">subrepo([pattern])</span></tt></dt>
117 <dd>Subrepositories whose paths match the given pattern.</dd>
118 <dt><tt class="docutils literal">symlink()</tt></dt>
119 <dd>File that is marked as a symlink.</dd>
120 <dt><tt class="docutils literal">tracked()</tt></dt>
121 <dd>File that is under Mercurial control.</dd>
122 <dt><tt class="docutils literal">unknown()</tt></dt>
123 <dd>File that is unknown according to <a class="reference external" href="hg-status.html"><tt class="docutils literal">hg status</tt></a>.</dd>
124 <dt><tt class="docutils literal">unresolved()</tt></dt>
125 <dd>File that is marked unresolved according to <a class="reference external" href="hg-resolve.html"><tt class="docutils literal">hg resolve <span class="pre">-l</span></tt></a>.</dd>
126 </dl>
127 </div>
128 <div class="section" id="examples">
129 <h1><a class="toc-backref" href="#contents">Examples</a></h1>
130 <p>Some sample queries:</p>
131 <ul>
132 <li><p class="first">Show status of files that appear to be binary in the working directory:</p>
133 <pre class="literal-block">
134 hg status -A &quot;set:binary()&quot;
135 </pre>
136 </li>
137 <li><p class="first">Forget files that are in .hgignore but are already tracked:</p>
138 <pre class="literal-block">
139 hg forget &quot;set:hgignore() and not ignored()&quot;
140 </pre>
141 </li>
142 <li><p class="first">Find text files that contain a string:</p>
143 <pre class="literal-block">
144 hg files &quot;set:grep(magic) and not binary()&quot;
145 </pre>
146 </li>
147 <li><p class="first">Find C files in a non-standard encoding:</p>
148 <pre class="literal-block">
149 hg files &quot;set:**.c and not encoding('UTF-8')&quot;
150 </pre>
151 </li>
152 <li><p class="first">Revert copies of large binary files:</p>
153 <pre class="literal-block">
154 hg revert &quot;set:copied() and binary() and size('&gt;1M')&quot;
155 </pre>
156 </li>
157 <li><p class="first">Revert files that were added to the working directory:</p>
158 <pre class="literal-block">
159 hg revert &quot;set:revs('wdir()', added())&quot;
160 </pre>
161 </li>
162 <li><p class="first">Remove files listed in foo.lst that contain the letter a or b:</p>
163 <pre class="literal-block">
164 hg remove &quot;set: listfile:foo.lst and (**a* or **b*)&quot;
165 </pre>
166 </li>
167 </ul>
168 </div>
169 </div>
170 </body>
171 </html>