| 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>Subrepositories</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="subrepositories"> |
| 12 |
<span id="topic-subrepos"></span> |
| 13 |
<h1 class="title">Subrepositories</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="#adding-a-subrepository" id="toc-entry-1">Adding a Subrepository</a></li> |
| 19 |
<li><a class="reference internal" href="#synchronizing-a-subrepository" id="toc-entry-2">Synchronizing a Subrepository</a></li> |
| 20 |
<li><a class="reference internal" href="#deleting-a-subrepository" id="toc-entry-3">Deleting a Subrepository</a></li> |
| 21 |
<li><a class="reference internal" href="#interaction-with-mercurial-commands" id="toc-entry-4">Interaction with Mercurial Commands</a></li> |
| 22 |
<li><a class="reference internal" href="#remapping-subrepositories-sources" id="toc-entry-5">Remapping Subrepositories Sources</a></li> |
| 23 |
</ul> |
| 24 |
</div> |
| 25 |
<p id="subrepo"><span id="subrepos"></span>Subrepositories let you nest external repositories or projects into a |
| 26 |
parent Mercurial repository, and make commands operate on them as a |
| 27 |
group.</p> |
| 28 |
<p>Mercurial currently supports Mercurial, Git, and Subversion |
| 29 |
subrepositories.</p> |
| 30 |
<p>Subrepositories are made of three components:</p> |
| 31 |
<ol class="arabic"> |
| 32 |
<li><p class="first">Nested repository checkouts. They can appear anywhere in the |
| 33 |
parent working directory.</p> |
| 34 |
</li> |
| 35 |
<li><p class="first">Nested repository references. They are defined in <tt class="docutils literal">.hgsub</tt>, which |
| 36 |
should be placed in the root of working directory, and |
| 37 |
tell where the subrepository checkouts come from. Mercurial |
| 38 |
subrepositories are referenced like:</p> |
| 39 |
<pre class="literal-block"> |
| 40 |
path/to/nested = https://example.com/nested/repo/path |
| 41 |
</pre> |
| 42 |
<p>Git and Subversion subrepos are also supported:</p> |
| 43 |
<pre class="literal-block"> |
| 44 |
path/to/nested = [git]git://example.com/nested/repo/path |
| 45 |
path/to/nested = [svn]https://example.com/nested/trunk/path |
| 46 |
</pre> |
| 47 |
<p>where <tt class="docutils literal">path/to/nested</tt> is the checkout location relatively to the |
| 48 |
parent Mercurial root, and <tt class="docutils literal"><span class="pre">https://example.com/nested/repo/path</span></tt> |
| 49 |
is the source repository path. The source can also reference a |
| 50 |
filesystem path.</p> |
| 51 |
<p>Note that <tt class="docutils literal">.hgsub</tt> does not exist by default in Mercurial |
| 52 |
repositories, you have to create and add it to the parent |
| 53 |
repository before using subrepositories.</p> |
| 54 |
</li> |
| 55 |
<li><p class="first">Nested repository states. They are defined in <tt class="docutils literal">.hgsubstate</tt>, which |
| 56 |
is placed in the root of working directory, and |
| 57 |
capture whatever information is required to restore the |
| 58 |
subrepositories to the state they were committed in a parent |
| 59 |
repository changeset. Mercurial automatically record the nested |
| 60 |
repositories states when committing in the parent repository.</p> |
| 61 |
<div class="admonition note"> |
| 62 |
<p class="first admonition-title">Note</p> |
| 63 |
<p class="last">The <tt class="docutils literal">.hgsubstate</tt> file should not be edited manually.</p> |
| 64 |
</div> |
| 65 |
</li> |
| 66 |
</ol> |
| 67 |
<div class="section" id="adding-a-subrepository"> |
| 68 |
<h1><a class="toc-backref" href="#contents">Adding a Subrepository</a></h1> |
| 69 |
<p>If <tt class="docutils literal">.hgsub</tt> does not exist, create it and add it to the parent |
| 70 |
repository. Clone or checkout the external projects where you want it |
| 71 |
to live in the parent repository. Edit <tt class="docutils literal">.hgsub</tt> and add the |
| 72 |
subrepository entry as described above. At this point, the |
| 73 |
subrepository is tracked and the next commit will record its state in |
| 74 |
<tt class="docutils literal">.hgsubstate</tt> and bind it to the committed changeset.</p> |
| 75 |
</div> |
| 76 |
<div class="section" id="synchronizing-a-subrepository"> |
| 77 |
<h1><a class="toc-backref" href="#contents">Synchronizing a Subrepository</a></h1> |
| 78 |
<p>Subrepos do not automatically track the latest changeset of their |
| 79 |
sources. Instead, they are updated to the changeset that corresponds |
| 80 |
with the changeset checked out in the top-level changeset. This is so |
| 81 |
developers always get a consistent set of compatible code and |
| 82 |
libraries when they update.</p> |
| 83 |
<p>Thus, updating subrepos is a manual process. Simply check out target |
| 84 |
subrepo at the desired revision, test in the top-level repo, then |
| 85 |
commit in the parent repository to record the new combination.</p> |
| 86 |
</div> |
| 87 |
<div class="section" id="deleting-a-subrepository"> |
| 88 |
<h1><a class="toc-backref" href="#contents">Deleting a Subrepository</a></h1> |
| 89 |
<p>To remove a subrepository from the parent repository, delete its |
| 90 |
reference from <tt class="docutils literal">.hgsub</tt>, then remove its files.</p> |
| 91 |
</div> |
| 92 |
<div class="section" id="interaction-with-mercurial-commands"> |
| 93 |
<h1><a class="toc-backref" href="#contents">Interaction with Mercurial Commands</a></h1> |
| 94 |
<table class="docutils field-list" frame="void" rules="none"> |
| 95 |
<col class="field-name" /> |
| 96 |
<col class="field-body" /> |
| 97 |
<tbody valign="top"> |
| 98 |
<tr class="field"><th class="field-name">add:</th><td class="field-body">add does not recurse in subrepos unless -S/--subrepos is |
| 99 |
specified. However, if you specify the full path of a file in a |
| 100 |
subrepo, it will be added even without -S/--subrepos specified. |
| 101 |
Subversion subrepositories are currently silently |
| 102 |
ignored.</td> |
| 103 |
</tr> |
| 104 |
<tr class="field"><th class="field-name">addremove:</th><td class="field-body">addremove does not recurse into subrepos unless |
| 105 |
-S/--subrepos is specified. However, if you specify the full |
| 106 |
path of a directory in a subrepo, addremove will be performed on |
| 107 |
it even without -S/--subrepos being specified. Git and |
| 108 |
Subversion subrepositories will print a warning and continue.</td> |
| 109 |
</tr> |
| 110 |
<tr class="field"><th class="field-name">archive:</th><td class="field-body">archive does not recurse in subrepositories unless |
| 111 |
-S/--subrepos is specified.</td> |
| 112 |
</tr> |
| 113 |
<tr class="field"><th class="field-name">cat:</th><td class="field-body">Git subrepositories only support exact file matches. |
| 114 |
Subversion subrepositories are currently ignored.</td> |
| 115 |
</tr> |
| 116 |
<tr class="field"><th class="field-name">commit:</th><td class="field-body">commit creates a consistent snapshot of the state of the |
| 117 |
entire project and its subrepositories. If any subrepositories |
| 118 |
have been modified, Mercurial will abort. Mercurial can be made |
| 119 |
to instead commit all modified subrepositories by specifying |
| 120 |
-S/--subrepos, or setting "ui.commitsubrepos=True" in a |
| 121 |
configuration file (see <a class="reference external" href="hgrc.5.html"><tt class="docutils literal">hg help config</tt></a>). After there are no |
| 122 |
longer any modified subrepositories, it records their state and |
| 123 |
finally commits it in the parent repository. The --addremove |
| 124 |
option also honors the -S/--subrepos option. However, Git and |
| 125 |
Subversion subrepositories will print a warning and abort.</td> |
| 126 |
</tr> |
| 127 |
<tr class="field"><th class="field-name">diff:</th><td class="field-body">diff does not recurse in subrepos unless -S/--subrepos is |
| 128 |
specified. However, if you specify the full path of a file or |
| 129 |
directory in a subrepo, it will be diffed even without |
| 130 |
-S/--subrepos being specified. Subversion subrepositories are |
| 131 |
currently silently ignored.</td> |
| 132 |
</tr> |
| 133 |
<tr class="field"><th class="field-name">files:</th><td class="field-body">files does not recurse into subrepos unless -S/--subrepos is |
| 134 |
specified. However, if you specify the full path of a file or |
| 135 |
directory in a subrepo, it will be displayed even without |
| 136 |
-S/--subrepos being specified. Git and Subversion subrepositories |
| 137 |
are currently silently ignored.</td> |
| 138 |
</tr> |
| 139 |
<tr class="field"><th class="field-name">forget:</th><td class="field-body">forget currently only handles exact file matches in subrepos. |
| 140 |
Git and Subversion subrepositories are currently silently ignored.</td> |
| 141 |
</tr> |
| 142 |
<tr class="field"><th class="field-name">incoming:</th><td class="field-body">incoming does not recurse in subrepos unless -S/--subrepos |
| 143 |
is specified. Git and Subversion subrepositories are currently |
| 144 |
silently ignored.</td> |
| 145 |
</tr> |
| 146 |
<tr class="field"><th class="field-name">outgoing:</th><td class="field-body">outgoing does not recurse in subrepos unless -S/--subrepos |
| 147 |
is specified. Git and Subversion subrepositories are currently |
| 148 |
silently ignored.</td> |
| 149 |
</tr> |
| 150 |
<tr class="field"><th class="field-name">pull:</th><td class="field-body">pull is not recursive since it is not clear what to pull prior |
| 151 |
to running <a class="reference external" href="hg-update.html"><tt class="docutils literal">hg update</tt></a>. Listing and retrieving all |
| 152 |
subrepositories changes referenced by the parent repository pulled |
| 153 |
changesets is expensive at best, impossible in the Subversion |
| 154 |
case.</td> |
| 155 |
</tr> |
| 156 |
<tr class="field"><th class="field-name">push:</th><td class="field-body">Mercurial will automatically push all subrepositories first |
| 157 |
when the parent repository is being pushed. This ensures new |
| 158 |
subrepository changes are available when referenced by top-level |
| 159 |
repositories. Push is a no-op for Subversion subrepositories.</td> |
| 160 |
</tr> |
| 161 |
<tr class="field"><th class="field-name">serve:</th><td class="field-body">serve does not recurse into subrepositories unless |
| 162 |
-S/--subrepos is specified. Git and Subversion subrepositories |
| 163 |
are currently silently ignored.</td> |
| 164 |
</tr> |
| 165 |
<tr class="field"><th class="field-name">status:</th><td class="field-body">status does not recurse into subrepositories unless |
| 166 |
-S/--subrepos is specified. Subrepository changes are displayed as |
| 167 |
regular Mercurial changes on the subrepository |
| 168 |
elements. Subversion subrepositories are currently silently |
| 169 |
ignored.</td> |
| 170 |
</tr> |
| 171 |
<tr class="field"><th class="field-name">remove:</th><td class="field-body">remove does not recurse into subrepositories unless |
| 172 |
-S/--subrepos is specified. However, if you specify a file or |
| 173 |
directory path in a subrepo, it will be removed even without |
| 174 |
-S/--subrepos. Git and Subversion subrepositories are currently |
| 175 |
silently ignored.</td> |
| 176 |
</tr> |
| 177 |
<tr class="field"><th class="field-name">update:</th><td class="field-body">update restores the subrepos in the state they were |
| 178 |
originally committed in target changeset. If the recorded |
| 179 |
changeset is not available in the current subrepository, Mercurial |
| 180 |
will pull it in first before updating. This means that updating |
| 181 |
can require network access when using subrepositories.</td> |
| 182 |
</tr> |
| 183 |
</tbody> |
| 184 |
</table> |
| 185 |
</div> |
| 186 |
<div class="section" id="remapping-subrepositories-sources"> |
| 187 |
<h1><a class="toc-backref" href="#contents">Remapping Subrepositories Sources</a></h1> |
| 188 |
<p>A subrepository source location may change during a project life, |
| 189 |
invalidating references stored in the parent repository history. To |
| 190 |
fix this, rewriting rules can be defined in parent repository <tt class="docutils literal">hgrc</tt> |
| 191 |
file or in Mercurial configuration. See the <tt class="docutils literal">[subpaths]</tt> section in |
| 192 |
hgrc(5) for more details.</p> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
</body> |
| 196 |
</html> |