| 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>largefiles</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="largefiles"> |
| 12 |
<span id="ext-largefiles"></span> |
| 13 |
<h1 class="title">largefiles</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></li> |
| 19 |
<li><a class="reference internal" href="#commands" id="toc-entry-2">Commands</a><ul> |
| 20 |
<li><a class="reference internal" href="#uncategorized-commands" id="toc-entry-3">Uncategorized commands</a></li> |
| 21 |
</ul> |
| 22 |
</li> |
| 23 |
</ul> |
| 24 |
</div> |
| 25 |
<p>track large binary files</p> |
| 26 |
<div class="section" id="description"> |
| 27 |
<h1><a class="toc-backref" href="#contents">Description</a></h1> |
| 28 |
<p>Large binary files tend to be not very compressible, not very |
| 29 |
diffable, and not at all mergeable. Such files are not handled |
| 30 |
efficiently by Mercurial's storage format (revlog), which is based on |
| 31 |
compressed binary deltas; storing large binary files as regular |
| 32 |
Mercurial files wastes bandwidth and disk space and increases |
| 33 |
Mercurial's memory usage. The largefiles extension addresses these |
| 34 |
problems by adding a centralized client-server layer on top of |
| 35 |
Mercurial: largefiles live in a <em>central store</em> out on the network |
| 36 |
somewhere, and you only fetch the revisions that you need when you |
| 37 |
need them.</p> |
| 38 |
<p>largefiles works by maintaining a "standin file" in .hglf/ for each |
| 39 |
largefile. The standins are small (41 bytes: an SHA-1 hash plus |
| 40 |
newline) and are tracked by Mercurial. Largefile revisions are |
| 41 |
identified by the SHA-1 hash of their contents, which is written to |
| 42 |
the standin. largefiles uses that revision ID to get/put largefile |
| 43 |
revisions from/to the central store. This saves both disk space and |
| 44 |
bandwidth, since you don't need to retrieve all historical revisions |
| 45 |
of large files when you clone or pull.</p> |
| 46 |
<p>To start a new repository or add new large binary files, just add |
| 47 |
--large to your <a class="reference external" href="hg-add.html"><tt class="docutils literal">hg add</tt></a> command. For example:</p> |
| 48 |
<pre class="literal-block"> |
| 49 |
$ dd if=/dev/urandom of=randomdata count=2000 |
| 50 |
$ hg add --large randomdata |
| 51 |
$ hg commit -m "add randomdata as a largefile" |
| 52 |
</pre> |
| 53 |
<p>When you push a changeset that adds/modifies largefiles to a remote |
| 54 |
repository, its largefile revisions will be uploaded along with it. |
| 55 |
Note that the remote Mercurial must also have the largefiles extension |
| 56 |
enabled for this to work.</p> |
| 57 |
<p>When you pull a changeset that affects largefiles from a remote |
| 58 |
repository, the largefiles for the changeset will by default not be |
| 59 |
pulled down. However, when you update to such a revision, any |
| 60 |
largefiles needed by that revision are downloaded and cached (if |
| 61 |
they have never been downloaded before). One way to pull largefiles |
| 62 |
when pulling is thus to use --update, which will update your working |
| 63 |
copy to the latest pulled revision (and thereby downloading any new |
| 64 |
largefiles).</p> |
| 65 |
<p>If you want to pull largefiles you don't need for update yet, then |
| 66 |
you can use pull with the <cite>--lfrev</cite> option or the <a class="reference external" href="hg-lfpull.html"><tt class="docutils literal">hg lfpull</tt></a> command.</p> |
| 67 |
<p>If you know you are pulling from a non-default location and want to |
| 68 |
download all the largefiles that correspond to the new changesets at |
| 69 |
the same time, then you can pull with <cite>--lfrev "pulled()"</cite>.</p> |
| 70 |
<p>If you just want to ensure that you will have the largefiles needed to |
| 71 |
merge or rebase with new heads that you are pulling, then you can pull |
| 72 |
with <cite>--lfrev "head(pulled())"</cite> flag to pre-emptively download any largefiles |
| 73 |
that are new in the heads you are pulling.</p> |
| 74 |
<p>Keep in mind that network access may now be required to update to |
| 75 |
changesets that you have not previously updated to. The nature of the |
| 76 |
largefiles extension means that updating is no longer guaranteed to |
| 77 |
be a local-only operation.</p> |
| 78 |
<p>If you already have large files tracked by Mercurial without the |
| 79 |
largefiles extension, you will need to convert your repository in |
| 80 |
order to benefit from largefiles. This is done with the |
| 81 |
<a class="reference external" href="hg-lfconvert.html"><tt class="docutils literal">hg lfconvert</tt></a> command:</p> |
| 82 |
<pre class="literal-block"> |
| 83 |
$ hg lfconvert --size 10 oldrepo newrepo |
| 84 |
</pre> |
| 85 |
<p>In repositories that already have largefiles in them, any new file |
| 86 |
over 10MB will automatically be added as a largefile. To change this |
| 87 |
threshold, set <tt class="docutils literal">largefiles.minsize</tt> in your Mercurial config file |
| 88 |
to the minimum size in megabytes to track as a largefile, or use the |
| 89 |
--lfsize option to the add command (also in megabytes):</p> |
| 90 |
<pre class="literal-block"> |
| 91 |
[largefiles] |
| 92 |
minsize = 2 |
| 93 |
|
| 94 |
$ hg add --lfsize 2 |
| 95 |
</pre> |
| 96 |
<p>The <tt class="docutils literal">largefiles.patterns</tt> config option allows you to specify a list |
| 97 |
of filename patterns (see <a class="reference external" href="topic-patterns.html"><tt class="docutils literal">hg help patterns</tt></a>) that should always be |
| 98 |
tracked as largefiles:</p> |
| 99 |
<pre class="literal-block"> |
| 100 |
[largefiles] |
| 101 |
patterns = |
| 102 |
*.jpg |
| 103 |
re:.*\.(png|bmp)$ |
| 104 |
library.zip |
| 105 |
content/audio/* |
| 106 |
</pre> |
| 107 |
<p>Files that match one of these patterns will be added as largefiles |
| 108 |
regardless of their size.</p> |
| 109 |
<p>The <tt class="docutils literal">largefiles.minsize</tt> and <tt class="docutils literal">largefiles.patterns</tt> config options |
| 110 |
will be ignored for any repositories not already containing a |
| 111 |
largefile. To add the first largefile to a repository, you must |
| 112 |
explicitly do so with the --large flag passed to the <a class="reference external" href="hg-add.html"><tt class="docutils literal">hg add</tt></a> |
| 113 |
command.</p> |
| 114 |
</div> |
| 115 |
<div class="section" id="commands"> |
| 116 |
<h1><a class="toc-backref" href="#contents">Commands</a></h1> |
| 117 |
<div class="section" id="uncategorized-commands"> |
| 118 |
<h2><a class="toc-backref" href="#contents">Uncategorized commands</a></h2> |
| 119 |
<div class="section" id="lfconvert"> |
| 120 |
<h3>lfconvert</h3> |
| 121 |
<p>convert a normal repository to a largefiles repository:</p> |
| 122 |
<pre class="literal-block"> |
| 123 |
hg lfconvert SOURCE DEST [FILE ...] |
| 124 |
</pre> |
| 125 |
<p>Convert repository SOURCE to a new repository DEST, identical to |
| 126 |
SOURCE except that certain files will be converted as largefiles: |
| 127 |
specifically, any file that matches any PATTERN <em>or</em> whose size is |
| 128 |
above the minimum size threshold is converted as a largefile. The |
| 129 |
size used to determine whether or not to track a file as a |
| 130 |
largefile is the size of the first version of the file. The |
| 131 |
minimum size can be specified either with --size or in |
| 132 |
configuration as <tt class="docutils literal">largefiles.size</tt>.</p> |
| 133 |
<p>After running this command you will need to make sure that |
| 134 |
largefiles is enabled anywhere you intend to push the new |
| 135 |
repository.</p> |
| 136 |
<p>Use --to-normal to convert largefiles back to normal files; after |
| 137 |
this, the DEST repository can be used without largefiles at all.</p> |
| 138 |
<p>Options:</p> |
| 139 |
<table class="docutils option-list" frame="void" rules="none"> |
| 140 |
<col class="option" /> |
| 141 |
<col class="description" /> |
| 142 |
<tbody valign="top"> |
| 143 |
<tr><td class="option-group" colspan="2"> |
| 144 |
<kbd><span class="option">-s</span>, <span class="option">--size <var><SIZE></var></span></kbd></td> |
| 145 |
</tr> |
| 146 |
<tr><td> </td><td>minimum size (MB) for files to be converted as largefiles</td></tr> |
| 147 |
<tr><td class="option-group"> |
| 148 |
<kbd><span class="option">--to-normal</span></kbd></td> |
| 149 |
<td>convert from a largefiles repo to a normal repo</td></tr> |
| 150 |
</tbody> |
| 151 |
</table> |
| 152 |
</div> |
| 153 |
<div class="section" id="lfpull"> |
| 154 |
<h3>lfpull</h3> |
| 155 |
<p>pull largefiles for the specified revisions from the specified source:</p> |
| 156 |
<pre class="literal-block"> |
| 157 |
hg lfpull -r REV... [-e CMD] [--remotecmd CMD] [SOURCE] |
| 158 |
</pre> |
| 159 |
<p>Pull largefiles that are referenced from local changesets but missing |
| 160 |
locally, pulling from a remote repository to the local cache.</p> |
| 161 |
<p>If SOURCE is omitted, the 'default' path will be used. |
| 162 |
See <a class="reference external" href="topic-urls.html"><tt class="docutils literal">hg help urls</tt></a> for more information.</p> |
| 163 |
<div class="verbose docutils container"> |
| 164 |
<p>Some examples:</p> |
| 165 |
<ul> |
| 166 |
<li><p class="first">pull largefiles for all branch heads:</p> |
| 167 |
<pre class="literal-block"> |
| 168 |
hg lfpull -r "head() and not closed()" |
| 169 |
</pre> |
| 170 |
</li> |
| 171 |
<li><p class="first">pull largefiles on the default branch:</p> |
| 172 |
<pre class="literal-block"> |
| 173 |
hg lfpull -r "branch(default)" |
| 174 |
</pre> |
| 175 |
</li> |
| 176 |
</ul> |
| 177 |
</div> |
| 178 |
<p>Options:</p> |
| 179 |
<table class="docutils option-list" frame="void" rules="none"> |
| 180 |
<col class="option" /> |
| 181 |
<col class="description" /> |
| 182 |
<tbody valign="top"> |
| 183 |
<tr><td class="option-group" colspan="2"> |
| 184 |
<kbd><span class="option">-r</span>, <span class="option">--rev <var><VALUE[+]></var></span></kbd></td> |
| 185 |
</tr> |
| 186 |
<tr><td> </td><td>pull largefiles for these revisions</td></tr> |
| 187 |
<tr><td class="option-group" colspan="2"> |
| 188 |
<kbd><span class="option">-e</span>, <span class="option">--ssh <var><CMD></var></span></kbd></td> |
| 189 |
</tr> |
| 190 |
<tr><td> </td><td>specify ssh command to use</td></tr> |
| 191 |
<tr><td class="option-group" colspan="2"> |
| 192 |
<kbd><span class="option">--remotecmd <var><CMD></var></span></kbd></td> |
| 193 |
</tr> |
| 194 |
<tr><td> </td><td>specify hg command to run on the remote side</td></tr> |
| 195 |
<tr><td class="option-group"> |
| 196 |
<kbd><span class="option">--insecure</span></kbd></td> |
| 197 |
<td>do not verify server certificate (ignoring web.cacerts config)</td></tr> |
| 198 |
</tbody> |
| 199 |
</table> |
| 200 |
<p>[+] marked option can be specified multiple times</p> |
| 201 |
</div> |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</div> |
| 205 |
</body> |
| 206 |
</html> |