| 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>narrow</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="narrow"> |
| 12 |
<span id="ext-narrow"></span> |
| 13 |
<h1 class="title">narrow</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="#description" id="toc-entry-1">Description</a><ul> |
| 19 |
<li><a class="reference internal" href="#concepts" id="toc-entry-2">Concepts</a></li> |
| 20 |
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li> |
| 21 |
</ul> |
| 22 |
</li> |
| 23 |
<li><a class="reference internal" href="#commands" id="toc-entry-4">Commands</a><ul> |
| 24 |
<li><a class="reference internal" href="#repository-maintenance" id="toc-entry-5">Repository maintenance</a></li> |
| 25 |
</ul> |
| 26 |
</li> |
| 27 |
</ul> |
| 28 |
</div> |
| 29 |
<p>create clones which fetch history data for subsets of files (EXPERIMENTAL)</p> |
| 30 |
<div class="section" id="description"> |
| 31 |
<h1><a class="toc-backref" href="#contents">Description</a></h1> |
| 32 |
<p>Only the server holds the full store: narrow clones will have the full history |
| 33 |
of fewer files in their store.</p> |
| 34 |
<div class="section" id="concepts"> |
| 35 |
<h2><a class="toc-backref" href="#contents">Concepts</a></h2> |
| 36 |
<p>The narrow extension introduces a number of concepts that are detailed below.</p> |
| 37 |
<div class="section" id="shape-experimental"> |
| 38 |
<h3>Shape (experimental)</h3> |
| 39 |
<p>A shape is used to define a set of paths to consider for clients of the narrow |
| 40 |
server. And it does so through the entire history, regardless the state of these |
| 41 |
files in the heads of the repository (deleted, for example).</p> |
| 42 |
<p>As of Mercurial 7.2, only a limited scope of all planned shape-related features |
| 43 |
have been implemented. Shapes are only directly interacted with by server |
| 44 |
administrators. They can be used to generate narrowspecs (used by clients) and |
| 45 |
to create narrow streaming clonebundles.</p> |
| 46 |
<p>This means that as of Mercurial 7.2, clients have no knowledge of shapes and |
| 47 |
must be given the set of narrow patterns by server administrators in order to |
| 48 |
use a streaming clonebundle for a given shape:</p> |
| 49 |
<pre class="literal-block"> |
| 50 |
$ hg clone server --narrow --narrowspec NARROW_SPEC_FILE |
| 51 |
</pre> |
| 52 |
</div> |
| 53 |
<div class="section" id="fingerprint"> |
| 54 |
<h3>Fingerprint</h3> |
| 55 |
<p>Every shape corresponds to a normalized and minimal set of included and excluded |
| 56 |
paths in a repository's store. This normalization ensures that we can derive a |
| 57 |
fingerprint, meaning that two shapes with the same fingerprint mean they match |
| 58 |
the same set of paths.</p> |
| 59 |
<p>Checking the fingerprint of a narrow clone can be done by running:</p> |
| 60 |
<pre class="literal-block"> |
| 61 |
$ hg admin::narrow-client --store-fingerprint |
| 62 |
</pre> |
| 63 |
<p>For now, we guarantee no stability of the fingerprints. Before we take shapes |
| 64 |
out of experimental, we will have a fingerprint versioning scheme, to allow |
| 65 |
for future changes with no confusion.</p> |
| 66 |
</div> |
| 67 |
<div class="section" id="shards"> |
| 68 |
<h3>Shards</h3> |
| 69 |
<p>Shards are used server-side to slice the store. Each shard is defined as a set |
| 70 |
of paths it contains: files or directories matching each path will be included |
| 71 |
in that shard. Moreover shards are mutually exclusive, meaning that a given file |
| 72 |
can only ever be in one shard and one shard only. When a shard's path matches a |
| 73 |
directory, the shard contains all files in that directory's tree, except for |
| 74 |
those matched by a more deeply nested shard.</p> |
| 75 |
</div> |
| 76 |
<div class="section" id="example"> |
| 77 |
<h3>Example</h3> |
| 78 |
<p>Given the following store, representing all files ever known to the repository:</p> |
| 79 |
<pre class="literal-block"> |
| 80 |
. |
| 81 |
├── file1 |
| 82 |
├── file2 |
| 83 |
└── foo |
| 84 |
└── bar |
| 85 |
├── baz |
| 86 |
│ ├── file1 |
| 87 |
│ └── file2 |
| 88 |
└── confidential |
| 89 |
├── confidential-file1 |
| 90 |
└── confidential-file2 |
| 91 |
</pre> |
| 92 |
<p>One could define the following shards:</p> |
| 93 |
<pre class="literal-block"> |
| 94 |
* ``foo``, that includes ``foo`` |
| 95 |
* ``foo.confidential``, that includes ``foo/bar/confidential`` |
| 96 |
</pre> |
| 97 |
<p>This would mean that shard <tt class="docutils literal">foo</tt> contains:</p> |
| 98 |
<pre class="literal-block"> |
| 99 |
* ``foo/bar/baz/file1`` |
| 100 |
* ``foo/bar/baz/file2`` |
| 101 |
</pre> |
| 102 |
<p>And shard <tt class="docutils literal">foo.confidential</tt> contains:</p> |
| 103 |
<pre class="literal-block"> |
| 104 |
* ``foo/bar/confidential/confidential-file1`` |
| 105 |
* ``foo/bar/confidential/confidential-file2`` |
| 106 |
</pre> |
| 107 |
<p>In this example, <tt class="docutils literal">file1</tt> and <tt class="docutils literal">file2</tt> are not contained in any explicitly |
| 108 |
defined shard. As a result, they are contained by the implicit <tt class="docutils literal">base</tt> shard.</p> |
| 109 |
<p>It is important to note that adding a new shard (e.g. that includes <cite>file1</cite> and |
| 110 |
<tt class="docutils literal">file2</tt>) would remove its paths from any shard that previously contained them |
| 111 |
(in this case, only <tt class="docutils literal">base</tt>).</p> |
| 112 |
<p>Server-side, shards are used to define shapes, which are sets of shards. Each |
| 113 |
shape defines the shards it includes, hence excluding the contents of all other |
| 114 |
shards.</p> |
| 115 |
<p>To simplify the creation of shapes, we can compose shards together by defining |
| 116 |
explicit dependencies between shards. In our above example, we could define a |
| 117 |
<tt class="docutils literal">foo.full</tt> (that does not itself have to define any paths), but requires both |
| 118 |
<tt class="docutils literal">foo</tt> and <tt class="docutils literal">foo.confidential</tt>, giving us a shard with the full <tt class="docutils literal">foo</tt> store |
| 119 |
subtree.</p> |
| 120 |
<p>Note that the set of paths in the current working copy may only be a subset of |
| 121 |
the the store. In our example, we can imagine that |
| 122 |
<tt class="docutils literal"><span class="pre">foo/bar/confidential-module</span></tt> has been split into the files in |
| 123 |
<tt class="docutils literal">foo/bar/confidential</tt> and removed from the working copy.</p> |
| 124 |
<p>In addition to the implicit <tt class="docutils literal">base</tt> shard, there is also the implicit |
| 125 |
<tt class="docutils literal"><span class="pre">.hg-files</span></tt> shard, which contains special paths used by Mercurial:</p> |
| 126 |
<pre class="literal-block"> |
| 127 |
* ``.hgignore`` |
| 128 |
* ``.hgtags`` |
| 129 |
* ``.hgsub`` |
| 130 |
* ``.hgsubstate`` |
| 131 |
</pre> |
| 132 |
<p>This shard will be automatically included in every <tt class="docutils literal">Shape</tt> to make sure |
| 133 |
Mercurial has the data it needs to operate on each revision.</p> |
| 134 |
</div> |
| 135 |
<div class="section" id="narrowspec-legacy"> |
| 136 |
<h3>Narrowspec (legacy)</h3> |
| 137 |
<p>Note: the narrowspec in its current form will be phased out in favor of the |
| 138 |
<tt class="docutils literal">Shape</tt> system within the next few versions of Mercurial, as of Mercurial 7.2. |
| 139 |
See the <tt class="docutils literal">Shapes vs narrowspec</tt> section below.</p> |
| 140 |
<p>The <tt class="docutils literal">narrowspec</tt> is a client-side configuration that consists of expressions |
| 141 |
to match remote files and/or directories that should be pulled |
| 142 |
into a client. The <tt class="docutils literal">narrowspec</tt> has <em>include</em> and <em>exclude</em> expressions, |
| 143 |
with excludes always trumping includes: that is, if a file matches an exclude |
| 144 |
expression, it will be excluded even if it also matches an include expression. |
| 145 |
Excluding files that were never included has no effect.</p> |
| 146 |
<p>Each included or excluded entry is in the format described by |
| 147 |
<a class="reference external" href="topic-patterns.html"><tt class="docutils literal">hg help patterns</tt></a>, but can only use <tt class="docutils literal">path:</tt> or <tt class="docutils literal">rootfilesin:</tt>, except |
| 148 |
when using <tt class="docutils literal">Shard</tt> and <tt class="docutils literal">Shape</tt> where you can only use <tt class="docutils literal">path:</tt>.</p> |
| 149 |
</div> |
| 150 |
<div class="section" id="shapes-vs-narrowspec"> |
| 151 |
<h3>Shapes vs narrowspec</h3> |
| 152 |
<p>The <tt class="docutils literal">narrowspec</tt> was introduced alongside the experimental narrow extension |
| 153 |
back in 2018. It enabled the client to chose exactly what it cares about from |
| 154 |
the server, with the server merely cooperating with the patterns that the |
| 155 |
client asks for.</p> |
| 156 |
<p>Unless this flexibility becomes really important for someone in the future, |
| 157 |
the current direction is to deprecate the narrowspec usage and remove its |
| 158 |
support entirely in later versions in favor of store shapes.</p> |
| 159 |
<p>Here the advantages of store shapes:</p> |
| 160 |
<pre class="literal-block"> |
| 161 |
* We can define clonebundles for usual patterns |
| 162 |
* We can nest and generally compose includes and excludes |
| 163 |
* We can generate a fingerprint for equivalent patterns |
| 164 |
* We can require that the server and the client agree on patterns |
| 165 |
* Client are made aware of changes on the server, invalidating their patterns |
| 166 |
* A solid permissions system could be built on top of store shapes |
| 167 |
* Some legacy problems (e.g. CLI parsing) will be solved |
| 168 |
</pre> |
| 169 |
<p>Some of these points could be (and have been) bolted on top of the original |
| 170 |
implementation, but we would not go very far.</p> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
<div class="section" id="usage"> |
| 174 |
<h2><a class="toc-backref" href="#contents">Usage</a></h2> |
| 175 |
<div class="section" id="server-configuration"> |
| 176 |
<h3>Server configuration</h3> |
| 177 |
<p>For Mercurial 7.2, the <tt class="docutils literal"><span class="pre">.hg/store/server-shapes</span></tt> file is a TOML file, to be |
| 178 |
created and modified directly by the narrow server's administrators.</p> |
| 179 |
<p><strong>Warning</strong>: using dedicated <tt class="docutils literal">hg</tt> command to modify the shapes config will |
| 180 |
become mandatory in future releases, once such a command exists, |
| 181 |
as changing shapes can lead to (sometimes surprising) client breakage.</p> |
| 182 |
<p>The current (experimental!) format is the following:</p> |
| 183 |
<pre class="literal-block"> |
| 184 |
* ``version`` (required): its value must be ``0`` |
| 185 |
* ``shards`` (required): a list of <shardconfig> |
| 186 |
* <shardconfig>: |
| 187 |
|
| 188 |
* ``name`` (required): canonical name for this shard. |
| 189 |
* ``paths`` (optional): A list of UTF8 paths that this shard concerns, |
| 190 |
relative to the repo root. |
| 191 |
* ``requires`` (optional): A list of the names of the shards that this |
| 192 |
shard depends on. |
| 193 |
* ``shape`` (optional): If ``true``, this as a user-accessible shape. |
| 194 |
</pre> |
| 195 |
<p>Constraints:</p> |
| 196 |
<pre class="literal-block"> |
| 197 |
* Shard names must be unique within the config |
| 198 |
* Shard names must only contain bytes that are either lowercase alphanumeric |
| 199 |
ascii, dot or hyphen |
| 200 |
* ``full``, ``base`` and ``.hg-files`` are reserved shard names |
| 201 |
* Each <shardconfig> must define one of ``requires`` or ``paths``, or both |
| 202 |
* Shard requirements cannot form a cycle |
| 203 |
* A given path cannot be in more than one shard |
| 204 |
* ``paths`` must be a list of UTF8 paths. Support for non-UTF8 paths will be |
| 205 |
added in an upcoming version, via an ``encoded_paths`` field |
| 206 |
* ``paths`` must be a list of syntactically valid paths relative to the |
| 207 |
repository root (no ``\n``, ``\r`` or ``\x00``, no consecutive slash, no |
| 208 |
slashes at the start or end, etc.) |
| 209 |
</pre> |
| 210 |
<p>Example:</p> |
| 211 |
<pre class="literal-block"> |
| 212 |
version = 0 |
| 213 |
|
| 214 |
[[shards]] |
| 215 |
name = "foo" |
| 216 |
paths = ["foo", "bar.txt", "baz/nested"] |
| 217 |
shape = true |
| 218 |
|
| 219 |
[[shards]] |
| 220 |
name = "subproject1" |
| 221 |
paths = ["subproject1", "utils/only-this-dir"] |
| 222 |
|
| 223 |
[[shards]] |
| 224 |
name = "backend" |
| 225 |
paths = ["subproject2"] |
| 226 |
requires = ["subproject1"] |
| 227 |
shape = true |
| 228 |
|
| 229 |
[[shards]] |
| 230 |
name = "full-stack" |
| 231 |
requires = ["backend", "foo"] |
| 232 |
shape = true |
| 233 |
</pre> |
| 234 |
</div> |
| 235 |
<div class="section" id="bundle-generation"> |
| 236 |
<h3>Bundle generation</h3> |
| 237 |
<p>Server administrators manually (and likely frequently) create streaming |
| 238 |
clonebundles for every shape and expose them in the server clonebundle manifest |
| 239 |
with their fingerprint. In future versions, non-streaming clonebundles will |
| 240 |
be supported and their generations more automated.</p> |
| 241 |
<p>You may generate the bundles with the following:</p> |
| 242 |
<pre class="literal-block"> |
| 243 |
$ hg bundle --all --type"none-v2;stream-v2;shape=my-shape" ../bundle.hg |
| 244 |
$ bundlespec="$(hg debugbundle --spec ../bundle.hg)" |
| 245 |
$ # [move bundle to static server or to `.hg/bundle-cache` for inline serving] |
| 246 |
$ bundleentry="https://static.com/bundle.hg BUNDLESPEC=$bundlespec" |
| 247 |
$ # [or use inline SSH clonebundles] |
| 248 |
$ bundleentry="peer-bundle-cache://bundle.hg BUNDLESPEC=$bundlespec" |
| 249 |
$ echo $bundleentry >> .hg/clonebundles.manifest |
| 250 |
</pre> |
| 251 |
<p>You can export the includes and exclude patterns for every shape and give |
| 252 |
them manually to clients:</p> |
| 253 |
<pre class="literal-block"> |
| 254 |
$ hg admin::narrow-server --shape-narrow-patterns my-shape |
| 255 |
[exclude] |
| 256 |
path:foo |
| 257 |
path:bar |
| 258 |
</pre> |
| 259 |
<p>Clients can then use said patterns when doing a narrow stream clone, which |
| 260 |
matches the fingerprint from the patterns with that of the server clonebundles:</p> |
| 261 |
<pre class="literal-block"> |
| 262 |
$ hg clone --narrow --narrowspec $NARROWSPECFILE |
| 263 |
</pre> |
| 264 |
</div> |
| 265 |
<div class="section" id="client"> |
| 266 |
<h3>Client</h3> |
| 267 |
<p>TODO explain current client-side config and how it might evolve (storing the |
| 268 |
shape, fingerprint, etc.).</p> |
| 269 |
</div> |
| 270 |
</div> |
| 271 |
</div> |
| 272 |
<div class="section" id="commands"> |
| 273 |
<h1><a class="toc-backref" href="#contents">Commands</a></h1> |
| 274 |
<div class="section" id="repository-maintenance"> |
| 275 |
<h2><a class="toc-backref" href="#contents">Repository maintenance</a></h2> |
| 276 |
<div class="section" id="tracked"> |
| 277 |
<h3>tracked</h3> |
| 278 |
<p>show or change the current narrowspec:</p> |
| 279 |
<pre class="literal-block"> |
| 280 |
hg tracked [OPTIONS]... [REMOTE] |
| 281 |
</pre> |
| 282 |
<p>With no argument, shows the current narrowspec entries, one per line. Each |
| 283 |
line will be prefixed with 'I' or 'X' for included or excluded patterns, |
| 284 |
respectively.</p> |
| 285 |
<p>The narrowspec is comprised of expressions to match remote files and/or |
| 286 |
directories that should be pulled into your client. |
| 287 |
The narrowspec has <em>include</em> and <em>exclude</em> expressions, with excludes always |
| 288 |
trumping includes: that is, if a file matches an exclude expression, it will |
| 289 |
be excluded even if it also matches an include expression. |
| 290 |
Excluding files that were never included has no effect.</p> |
| 291 |
<p>Each included or excluded entry is in the format described by |
| 292 |
'hg help patterns'.</p> |
| 293 |
<p>The options allow you to add or remove included and excluded expressions.</p> |
| 294 |
<p>If --clear is specified, then all previous includes and excludes are DROPPED |
| 295 |
and replaced by the new ones specified to --addinclude and --addexclude. |
| 296 |
If --clear is specified without any further options, the narrowspec will be |
| 297 |
empty and will not match any files.</p> |
| 298 |
<p>If --auto-remove-includes is specified, then those includes that don't match |
| 299 |
any files modified by currently visible local commits (those not shared by |
| 300 |
the remote) will be added to the set of explicitly specified includes to |
| 301 |
remove.</p> |
| 302 |
<p>--import-rules accepts a path to a file containing rules, allowing you to |
| 303 |
add --addinclude, --addexclude rules in bulk. Like the other include and |
| 304 |
exclude switches, the changes are applied immediately.</p> |
| 305 |
<p>Options:</p> |
| 306 |
<table class="docutils option-list" frame="void" rules="none"> |
| 307 |
<col class="option" /> |
| 308 |
<col class="description" /> |
| 309 |
<tbody valign="top"> |
| 310 |
<tr><td class="option-group" colspan="2"> |
| 311 |
<kbd><span class="option">--addinclude <var><VALUE[+]></var></span></kbd></td> |
| 312 |
</tr> |
| 313 |
<tr><td> </td><td>new paths to include</td></tr> |
| 314 |
<tr><td class="option-group" colspan="2"> |
| 315 |
<kbd><span class="option">--removeinclude <var><VALUE[+]></var></span></kbd></td> |
| 316 |
</tr> |
| 317 |
<tr><td> </td><td>old paths to no longer include</td></tr> |
| 318 |
<tr><td class="option-group" colspan="2"> |
| 319 |
<kbd><span class="option">--auto-remove-includes</span></kbd></td> |
| 320 |
</tr> |
| 321 |
<tr><td> </td><td>automatically choose unused includes to remove</td></tr> |
| 322 |
<tr><td class="option-group" colspan="2"> |
| 323 |
<kbd><span class="option">--addexclude <var><VALUE[+]></var></span></kbd></td> |
| 324 |
</tr> |
| 325 |
<tr><td> </td><td>new paths to exclude</td></tr> |
| 326 |
<tr><td class="option-group" colspan="2"> |
| 327 |
<kbd><span class="option">--import-rules <var><VALUE></var></span></kbd></td> |
| 328 |
</tr> |
| 329 |
<tr><td> </td><td>import narrowspecs from a file</td></tr> |
| 330 |
<tr><td class="option-group" colspan="2"> |
| 331 |
<kbd><span class="option">--removeexclude <var><VALUE[+]></var></span></kbd></td> |
| 332 |
</tr> |
| 333 |
<tr><td> </td><td>old paths to no longer exclude</td></tr> |
| 334 |
<tr><td class="option-group"> |
| 335 |
<kbd><span class="option">--clear</span></kbd></td> |
| 336 |
<td>whether to replace the existing narrowspec</td></tr> |
| 337 |
<tr><td class="option-group" colspan="2"> |
| 338 |
<kbd><span class="option">--force-delete-local-changes</span></kbd></td> |
| 339 |
</tr> |
| 340 |
<tr><td> </td><td>forces deletion of local changes when narrowing</td></tr> |
| 341 |
<tr><td class="option-group"> |
| 342 |
<kbd><span class="option">--backup</span></kbd></td> |
| 343 |
<td>back up local changes when narrowing (default: True)</td></tr> |
| 344 |
<tr><td class="option-group" colspan="2"> |
| 345 |
<kbd><span class="option">--update-working-copy</span></kbd></td> |
| 346 |
</tr> |
| 347 |
<tr><td> </td><td>update working copy when the store has changed</td></tr> |
| 348 |
<tr><td class="option-group" colspan="2"> |
| 349 |
<kbd><span class="option">-e</span>, <span class="option">--ssh <var><CMD></var></span></kbd></td> |
| 350 |
</tr> |
| 351 |
<tr><td> </td><td>specify ssh command to use</td></tr> |
| 352 |
<tr><td class="option-group" colspan="2"> |
| 353 |
<kbd><span class="option">--remotecmd <var><CMD></var></span></kbd></td> |
| 354 |
</tr> |
| 355 |
<tr><td> </td><td>specify hg command to run on the remote side</td></tr> |
| 356 |
<tr><td class="option-group"> |
| 357 |
<kbd><span class="option">--insecure</span></kbd></td> |
| 358 |
<td>do not verify server certificate (ignoring web.cacerts config)</td></tr> |
| 359 |
</tbody> |
| 360 |
</table> |
| 361 |
<p>[+] marked option can be specified multiple times</p> |
| 362 |
</div> |
| 363 |
</div> |
| 364 |
</div> |
| 365 |
</div> |
| 366 |
</body> |
| 367 |
</html> |