| 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>hg import</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="hg-import"> |
| 12 |
<span id="hg-import-1"></span> |
| 13 |
<h1 class="title">hg import</h1> |
| 14 |
<h2 class="subtitle" id="import-an-ordered-set-of-patches">import an ordered set of patches</h2> |
| 15 |
|
| 16 |
<div class="contents htmlonly topic" id="contents"> |
| 17 |
<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p> |
| 18 |
<ul class="simple"> |
| 19 |
<li><a class="reference internal" href="#synopsis" id="toc-entry-1">Synopsis</a></li> |
| 20 |
<li><a class="reference internal" href="#description" id="toc-entry-2">Description</a></li> |
| 21 |
<li><a class="reference internal" href="#options" id="toc-entry-3">Options</a></li> |
| 22 |
<li><a class="reference internal" href="#aliases" id="toc-entry-4">Aliases</a></li> |
| 23 |
</ul> |
| 24 |
</div> |
| 25 |
<div class="section" id="synopsis"> |
| 26 |
<h1><a class="toc-backref" href="#contents">Synopsis</a></h1> |
| 27 |
<pre class="literal-block"> |
| 28 |
hg import [OPTION]... PATCH... |
| 29 |
</pre> |
| 30 |
</div> |
| 31 |
<div class="section" id="description"> |
| 32 |
<h1><a class="toc-backref" href="#contents">Description</a></h1> |
| 33 |
<p>Import a list of patches and commit them individually (unless |
| 34 |
--no-commit is specified).</p> |
| 35 |
<p>To read a patch from standard input (stdin), use "-" as the patch |
| 36 |
name. If a URL is specified, the patch will be downloaded from |
| 37 |
there.</p> |
| 38 |
<p>Import first applies changes to the working directory (unless |
| 39 |
--bypass is specified), import will abort if there are outstanding |
| 40 |
changes.</p> |
| 41 |
<p>Use --bypass to apply and commit patches directly to the |
| 42 |
repository, without affecting the working directory. Without |
| 43 |
--exact, patches will be applied on top of the working directory |
| 44 |
parent revision.</p> |
| 45 |
<p>You can import a patch straight from a mail message. Even patches |
| 46 |
as attachments work (to use the body part, it must have type |
| 47 |
text/plain or text/x-patch). From and Subject headers of email |
| 48 |
message are used as default committer and commit message. All |
| 49 |
text/plain body parts before first diff are added to the commit |
| 50 |
message.</p> |
| 51 |
<p>If the imported patch was generated by <a class="reference external" href="hg-export.html"><tt class="docutils literal">hg export</tt></a>, user and |
| 52 |
description from patch override values from message headers and |
| 53 |
body. Values given on command line with -m/--message and -u/--user |
| 54 |
override these.</p> |
| 55 |
<p>If --exact is specified, import will set the working directory to |
| 56 |
the parent of each patch before applying it, and will abort if the |
| 57 |
resulting changeset has a different ID than the one recorded in |
| 58 |
the patch. This will guard against various ways that portable |
| 59 |
patch formats and mail systems might fail to transfer Mercurial |
| 60 |
data or metadata. See <a class="reference external" href="hg-bundle.html"><tt class="docutils literal">hg bundle</tt></a> for lossless transmission.</p> |
| 61 |
<p>Use --partial to ensure a changeset will be created from the patch |
| 62 |
even if some hunks fail to apply. Hunks that fail to apply will be |
| 63 |
written to a <target-file>.rej file. Conflicts can then be resolved |
| 64 |
by hand before <a class="reference external" href="hg-commit.html"><tt class="docutils literal">hg commit <span class="pre">--amend</span></tt></a> is run to update the created |
| 65 |
changeset. This flag exists to let people import patches that |
| 66 |
partially apply without losing the associated metadata (author, |
| 67 |
date, description, ...).</p> |
| 68 |
<div class="admonition note"> |
| 69 |
<p class="first admonition-title">Note</p> |
| 70 |
<p class="last">When no hunks apply cleanly, <a class="reference external" href="hg-import.html"><tt class="docutils literal">hg import <span class="pre">--partial</span></tt></a> will create |
| 71 |
an empty changeset, importing only the patch metadata.</p> |
| 72 |
</div> |
| 73 |
<p>With -s/--similarity, hg will attempt to discover renames and |
| 74 |
copies in the patch in the same way as <a class="reference external" href="hg-addremove.html"><tt class="docutils literal">hg addremove</tt></a>.</p> |
| 75 |
<p>It is possible to use external patch programs to perform the patch |
| 76 |
by setting the <tt class="docutils literal">ui.patch</tt> configuration option. For the default |
| 77 |
internal tool, the fuzz can also be configured via <tt class="docutils literal">patch.fuzz</tt>. |
| 78 |
See <a class="reference external" href="hgrc.5.html"><tt class="docutils literal">hg help config</tt></a> for more information about configuration |
| 79 |
files and how to use these options.</p> |
| 80 |
<p>See <a class="reference external" href="topic-dates.html"><tt class="docutils literal">hg help dates</tt></a> for a list of formats valid for -d/--date.</p> |
| 81 |
<div class="verbose docutils container"> |
| 82 |
<p>Examples:</p> |
| 83 |
<ul> |
| 84 |
<li><p class="first">import a traditional patch from a website and detect renames:</p> |
| 85 |
<pre class="literal-block"> |
| 86 |
hg import -s 80 http://example.com/bugfix.patch |
| 87 |
</pre> |
| 88 |
</li> |
| 89 |
<li><p class="first">import a changeset from an hgweb server:</p> |
| 90 |
<pre class="literal-block"> |
| 91 |
hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa |
| 92 |
</pre> |
| 93 |
</li> |
| 94 |
<li><p class="first">import all the patches in an Unix-style mbox:</p> |
| 95 |
<pre class="literal-block"> |
| 96 |
hg import incoming-patches.mbox |
| 97 |
</pre> |
| 98 |
</li> |
| 99 |
<li><p class="first">import patches from stdin:</p> |
| 100 |
<pre class="literal-block"> |
| 101 |
hg import - |
| 102 |
</pre> |
| 103 |
</li> |
| 104 |
<li><p class="first">attempt to exactly restore an exported changeset (not always |
| 105 |
possible):</p> |
| 106 |
<pre class="literal-block"> |
| 107 |
hg import --exact proposed-fix.patch |
| 108 |
</pre> |
| 109 |
</li> |
| 110 |
<li><p class="first">use an external tool to apply a patch which is too fuzzy for |
| 111 |
the default internal tool.</p> |
| 112 |
<blockquote> |
| 113 |
<p>hg import --config ui.patch="patch --merge" fuzzy.patch</p> |
| 114 |
</blockquote> |
| 115 |
</li> |
| 116 |
<li><p class="first">change the default fuzzing from 2 to a less strict 7</p> |
| 117 |
<blockquote> |
| 118 |
<p>hg import --config ui.fuzz=7 fuzz.patch</p> |
| 119 |
</blockquote> |
| 120 |
</li> |
| 121 |
</ul> |
| 122 |
</div> |
| 123 |
<p>Returns 0 on success, 1 on partial success (see --partial).</p> |
| 124 |
</div> |
| 125 |
<div class="section" id="options"> |
| 126 |
<h1><a class="toc-backref" href="#contents">Options</a></h1> |
| 127 |
<table class="docutils option-list" frame="void" rules="none"> |
| 128 |
<col class="option" /> |
| 129 |
<col class="description" /> |
| 130 |
<tbody valign="top"> |
| 131 |
<tr><td class="option-group" colspan="2"> |
| 132 |
<kbd><span class="option">-p</span>, <span class="option">--strip <var><NUM></var></span></kbd></td> |
| 133 |
</tr> |
| 134 |
<tr><td> </td><td>directory strip option for patch. This has the same meaning as the corresponding patch option (default: 1)</td></tr> |
| 135 |
<tr><td class="option-group" colspan="2"> |
| 136 |
<kbd><span class="option">-b</span>, <span class="option">--base <var><PATH></var></span></kbd></td> |
| 137 |
</tr> |
| 138 |
<tr><td> </td><td>base path (DEPRECATED)</td></tr> |
| 139 |
<tr><td class="option-group"> |
| 140 |
<kbd><span class="option">--secret</span></kbd></td> |
| 141 |
<td>use the secret phase for committing</td></tr> |
| 142 |
<tr><td class="option-group"> |
| 143 |
<kbd><span class="option">-e</span>, <span class="option">--edit</span></kbd></td> |
| 144 |
<td>invoke editor on commit messages</td></tr> |
| 145 |
<tr><td class="option-group"> |
| 146 |
<kbd><span class="option">-f</span>, <span class="option">--force</span></kbd></td> |
| 147 |
<td>skip check for outstanding uncommitted changes (DEPRECATED)</td></tr> |
| 148 |
<tr><td class="option-group"> |
| 149 |
<kbd><span class="option">--no-commit</span></kbd></td> |
| 150 |
<td>don't commit, just update the working directory</td></tr> |
| 151 |
<tr><td class="option-group"> |
| 152 |
<kbd><span class="option">--bypass</span></kbd></td> |
| 153 |
<td>apply patch without touching the working directory</td></tr> |
| 154 |
<tr><td class="option-group"> |
| 155 |
<kbd><span class="option">--partial</span></kbd></td> |
| 156 |
<td>commit even if some hunks fail</td></tr> |
| 157 |
<tr><td class="option-group"> |
| 158 |
<kbd><span class="option">--exact</span></kbd></td> |
| 159 |
<td>abort if patch would apply lossily</td></tr> |
| 160 |
<tr><td class="option-group"> |
| 161 |
<kbd><span class="option">--prefix <var><DIR></var></span></kbd></td> |
| 162 |
<td>apply patch to subdirectory</td></tr> |
| 163 |
<tr><td class="option-group" colspan="2"> |
| 164 |
<kbd><span class="option">--import-branch</span></kbd></td> |
| 165 |
</tr> |
| 166 |
<tr><td> </td><td>use any branch information in patch (implied by --exact)</td></tr> |
| 167 |
<tr><td class="option-group" colspan="2"> |
| 168 |
<kbd><span class="option">-m</span>, <span class="option">--message <var><TEXT></var></span></kbd></td> |
| 169 |
</tr> |
| 170 |
<tr><td> </td><td>use text as commit message</td></tr> |
| 171 |
<tr><td class="option-group" colspan="2"> |
| 172 |
<kbd><span class="option">-l</span>, <span class="option">--logfile <var><FILE></var></span></kbd></td> |
| 173 |
</tr> |
| 174 |
<tr><td> </td><td>read commit message from file</td></tr> |
| 175 |
<tr><td class="option-group" colspan="2"> |
| 176 |
<kbd><span class="option">-d</span>, <span class="option">--date <var><DATE></var></span></kbd></td> |
| 177 |
</tr> |
| 178 |
<tr><td> </td><td>record the specified date as commit date</td></tr> |
| 179 |
<tr><td class="option-group" colspan="2"> |
| 180 |
<kbd><span class="option">-u</span>, <span class="option">--user <var><USER></var></span></kbd></td> |
| 181 |
</tr> |
| 182 |
<tr><td> </td><td>record the specified user as committer</td></tr> |
| 183 |
<tr><td class="option-group" colspan="2"> |
| 184 |
<kbd><span class="option">-s</span>, <span class="option">--similarity <var><SIMILARITY></var></span></kbd></td> |
| 185 |
</tr> |
| 186 |
<tr><td> </td><td>guess renamed files by similarity (0<=s<=100)</td></tr> |
| 187 |
</tbody> |
| 188 |
</table> |
| 189 |
</div> |
| 190 |
<div class="section" id="aliases"> |
| 191 |
<h1><a class="toc-backref" href="#contents">Aliases</a></h1> |
| 192 |
<pre class="literal-block"> |
| 193 |
patch |
| 194 |
</pre> |
| 195 |
</div> |
| 196 |
</div> |
| 197 |
</body> |
| 198 |
</html> |