Debian Codegraph @

doc/html/hg-graft.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>hg graft</title>
8 <link rel="stylesheet" href="../style.css" type="text/css" />
9 </head>
10 <body>
11 <div class="document" id="hg-graft">
12 <span id="hg-graft-1"></span>
13 <h1 class="title">hg graft</h1>
14 <h2 class="subtitle" id="copy-changes-from-other-branches-onto-the-current-branch">copy changes from other branches onto the current branch</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 </ul>
23 </div>
24 <div class="section" id="synopsis">
25 <h1><a class="toc-backref" href="#contents">Synopsis</a></h1>
26 <pre class="literal-block">
27 hg graft [OPTION]... [-r REV]... REV...
28 </pre>
29 </div>
30 <div class="section" id="description">
31 <h1><a class="toc-backref" href="#contents">Description</a></h1>
32 <p>This command uses Mercurial's merge logic to copy individual
33 changes from other branches without merging branches in the
34 history graph. This is sometimes known as 'backporting' or
35 'cherry-picking'. By default, graft will copy user, date, and
36 description from the source changesets.</p>
37 <p>Changesets that are ancestors of the current revision, that have
38 already been grafted, or that are merges will be skipped.</p>
39 <p>If --log is specified, log messages will have a comment appended
40 of the form:</p>
41 <pre class="literal-block">
42 (grafted from CHANGESETHASH)
43 </pre>
44 <p>If --force is specified, revisions will be grafted even if they
45 are already ancestors of, or have been grafted to, the destination.
46 This is useful when the revisions have since been backed out.</p>
47 <p>If a graft merge results in conflicts, the graft process is
48 interrupted so that the current merge can be manually resolved.
49 Once all conflicts are addressed, the graft process can be
50 continued with the -c/--continue option.</p>
51 <p>The -c/--continue option reapplies all the earlier options.</p>
52 <div class="verbose docutils container">
53 <p>The --base option exposes more of how graft internally uses merge with a
54 custom base revision. --base can be used to specify another ancestor than
55 the first and only parent.</p>
56 <p>The command:</p>
57 <pre class="literal-block">
58 hg graft -r 345 --base 234
59 </pre>
60 <p>is thus pretty much the same as:</p>
61 <pre class="literal-block">
62 hg diff --from 234 --to 345 | hg import
63 </pre>
64 <p>but using merge to resolve conflicts and track moved files.</p>
65 <p>The result of a merge can thus be backported as a single commit by
66 specifying one of the merge parents as base, and thus effectively
67 grafting the changes from the other side.</p>
68 <p>It is also possible to collapse multiple changesets and clean up history
69 by specifying another ancestor as base, much like rebase --collapse
70 --keep.</p>
71 <p>The commit message can be tweaked after the fact using commit --amend .</p>
72 <p>For using non-ancestors as the base to backout changes, see the backout
73 command and the hidden --parent option.</p>
74 </div>
75 <div class="verbose docutils container">
76 <p>The experimental --to option allows grafting a revision in-memory,
77 independent of the working copy. Merge conflicts are not currently
78 supported, and the operation will be aborted if the configured tool
79 cannot handle the conflicts that might be encountered.</p>
80 <p>As the operation is performed in-memory, the on-disk files will not be
81 modified, and some hooks might not be run.</p>
82 </div>
83 <div class="verbose docutils container">
84 <p>Examples:</p>
85 <ul>
86 <li><p class="first">copy a single change to the stable branch and edit its description:</p>
87 <pre class="literal-block">
88 hg update stable
89 hg graft --edit 9393
90 </pre>
91 </li>
92 <li><p class="first">graft a range of changesets with one exception, updating dates:</p>
93 <pre class="literal-block">
94 hg graft -D &quot;2085::2093 and not 2091&quot;
95 </pre>
96 </li>
97 <li><p class="first">continue a graft after resolving conflicts:</p>
98 <pre class="literal-block">
99 hg graft -c
100 </pre>
101 </li>
102 <li><p class="first">show the source of a grafted changeset:</p>
103 <pre class="literal-block">
104 hg log --debug -r .
105 </pre>
106 </li>
107 <li><p class="first">show revisions sorted by date:</p>
108 <pre class="literal-block">
109 hg log -r &quot;sort(all(), date)&quot;
110 </pre>
111 </li>
112 <li><p class="first">backport the result of a merge as a single commit:</p>
113 <pre class="literal-block">
114 hg graft -r 123 --base 123^
115 </pre>
116 </li>
117 <li><p class="first">land a feature branch as one changeset:</p>
118 <pre class="literal-block">
119 hg up -cr default
120 hg graft -r featureX --base &quot;ancestor('featureX', 'default')&quot;
121 </pre>
122 </li>
123 </ul>
124 </div>
125 <p>See <a class="reference external" href="topic-revisions.html"><tt class="docutils literal">hg help revisions</tt></a> for more about specifying revisions.</p>
126 <p>Returns 0 on successful completion, 1 if there are unresolved files.</p>
127 </div>
128 <div class="section" id="options">
129 <h1><a class="toc-backref" href="#contents">Options</a></h1>
130 <table class="docutils option-list" frame="void" rules="none">
131 <col class="option" />
132 <col class="description" />
133 <tbody valign="top">
134 <tr><td class="option-group" colspan="2">
135 <kbd><span class="option">-r</span>, <span class="option">--rev <var>&lt;REV[+]&gt;</var></span></kbd></td>
136 </tr>
137 <tr><td>&nbsp;</td><td>revisions to graft</td></tr>
138 <tr><td class="option-group">
139 <kbd><span class="option">--base <var>&lt;REV&gt;</var></span></kbd></td>
140 <td>base revision when doing the graft merge (ADVANCED)</td></tr>
141 <tr><td class="option-group">
142 <kbd><span class="option">--to <var>&lt;VALUE&gt;</var></span></kbd></td>
143 <td>graft to this destination, in-memory (EXPERIMENTAL)</td></tr>
144 <tr><td class="option-group">
145 <kbd><span class="option">-c</span>, <span class="option">--continue</span></kbd></td>
146 <td>resume interrupted graft</td></tr>
147 <tr><td class="option-group">
148 <kbd><span class="option">--stop</span></kbd></td>
149 <td>stop interrupted graft</td></tr>
150 <tr><td class="option-group">
151 <kbd><span class="option">--abort</span></kbd></td>
152 <td>abort interrupted graft</td></tr>
153 <tr><td class="option-group">
154 <kbd><span class="option">-e</span>, <span class="option">--edit</span></kbd></td>
155 <td>invoke editor on commit messages</td></tr>
156 <tr><td class="option-group">
157 <kbd><span class="option">--log</span></kbd></td>
158 <td>append graft info to log message</td></tr>
159 <tr><td class="option-group">
160 <kbd><span class="option">--no-commit</span></kbd></td>
161 <td>don't commit, just apply the changes in working directory</td></tr>
162 <tr><td class="option-group">
163 <kbd><span class="option">-f</span>, <span class="option">--force</span></kbd></td>
164 <td>force graft</td></tr>
165 <tr><td class="option-group" colspan="2">
166 <kbd><span class="option">-D</span>, <span class="option">--currentdate</span></kbd></td>
167 </tr>
168 <tr><td>&nbsp;</td><td>record the current date as commit date</td></tr>
169 <tr><td class="option-group" colspan="2">
170 <kbd><span class="option">-U</span>, <span class="option">--currentuser</span></kbd></td>
171 </tr>
172 <tr><td>&nbsp;</td><td>record the current user as committer</td></tr>
173 <tr><td class="option-group" colspan="2">
174 <kbd><span class="option">-d</span>, <span class="option">--date <var>&lt;DATE&gt;</var></span></kbd></td>
175 </tr>
176 <tr><td>&nbsp;</td><td>record the specified date as commit date</td></tr>
177 <tr><td class="option-group" colspan="2">
178 <kbd><span class="option">-u</span>, <span class="option">--user <var>&lt;USER&gt;</var></span></kbd></td>
179 </tr>
180 <tr><td>&nbsp;</td><td>record the specified user as committer</td></tr>
181 <tr><td class="option-group" colspan="2">
182 <kbd><span class="option">-t</span>, <span class="option">--tool <var>&lt;TOOL&gt;</var></span></kbd></td>
183 </tr>
184 <tr><td>&nbsp;</td><td>specify merge tool</td></tr>
185 <tr><td class="option-group">
186 <kbd><span class="option">-n</span>, <span class="option">--dry-run</span></kbd></td>
187 <td>do not perform actions, just print output</td></tr>
188 </tbody>
189 </table>
190 <p>[+] marked option can be specified multiple times</p>
191 </div>
192 </div>
193 </body>
194 </html>