Debian Codegraph @

doc/html/ext-rebase.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>rebase</title>
8 <link rel="stylesheet" href="../style.css" type="text/css" />
9 </head>
10 <body>
11 <div class="document" id="rebase">
12 <span id="ext-rebase"></span>
13 <h1 class="title">rebase</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="#change-manipulation" id="toc-entry-3">Change manipulation</a></li>
21 </ul>
22 </li>
23 </ul>
24 </div>
25 <p>command to move sets of revisions to a different ancestor</p>
26 <div class="section" id="description">
27 <h1><a class="toc-backref" href="#contents">Description</a></h1>
28 <p>This extension lets you rebase changesets in an existing Mercurial
29 repository.</p>
30 <p>For more information:
31 <a class="reference external" href="https://mercurial-scm.org/wiki/RebaseExtension">https://mercurial-scm.org/wiki/RebaseExtension</a></p>
32 </div>
33 <div class="section" id="commands">
34 <h1><a class="toc-backref" href="#contents">Commands</a></h1>
35 <div class="section" id="change-manipulation">
36 <h2><a class="toc-backref" href="#contents">Change manipulation</a></h2>
37 <div class="section" id="rebase-1">
38 <h3>rebase</h3>
39 <p>move changeset (and descendants) to a different branch:</p>
40 <pre class="literal-block">
41 hg rebase [[-s REV]... | [-b REV]... | [-r REV]...] [-d REV] [OPTION]...
42 </pre>
43 <p>Rebase uses repeated merging to graft changesets from one part of
44 history (the source) onto another (the destination). This can be
45 useful for linearizing <em>local</em> changes relative to a master
46 development tree.</p>
47 <p>Published commits cannot be rebased (see <a class="reference external" href="topic-phases.html"><tt class="docutils literal">hg help phases</tt></a>).
48 To copy commits, see <a class="reference external" href="hg-graft.html"><tt class="docutils literal">hg help graft</tt></a>.</p>
49 <p>If you don't specify a destination changeset (<tt class="docutils literal"><span class="pre">-d/--dest</span></tt>), rebase
50 will use the same logic as <a class="reference external" href="hg-merge.html"><tt class="docutils literal">hg merge</tt></a> to pick a destination. if
51 the current branch contains exactly one other head, the other head
52 is merged with by default. Otherwise, an explicit revision with
53 which to merge with must be provided. (destination changeset is not
54 modified by rebasing, but new changesets are added as its
55 descendants.)</p>
56 <p>Here are the ways to select changesets:</p>
57 <blockquote>
58 <ol class="arabic simple">
59 <li>Explicitly select them using <tt class="docutils literal"><span class="pre">--rev</span></tt>.</li>
60 <li>Use <tt class="docutils literal"><span class="pre">--source</span></tt> to select a root changeset and include all of its
61 descendants.</li>
62 <li>Use <tt class="docutils literal"><span class="pre">--base</span></tt> to select a changeset; rebase will find ancestors
63 and their descendants which are not also ancestors of the destination.</li>
64 <li>If you do not specify any of <tt class="docutils literal"><span class="pre">--rev</span></tt>, <tt class="docutils literal"><span class="pre">--source</span></tt>, or <tt class="docutils literal"><span class="pre">--base</span></tt>,
65 rebase will use <tt class="docutils literal"><span class="pre">--base</span> .</tt> as above.</li>
66 </ol>
67 </blockquote>
68 <p>If <tt class="docutils literal"><span class="pre">--source</span></tt> or <tt class="docutils literal"><span class="pre">--rev</span></tt> is used, special names <tt class="docutils literal">SRC</tt> and <tt class="docutils literal">ALLSRC</tt>
69 can be used in <tt class="docutils literal"><span class="pre">--dest</span></tt>. Destination would be calculated per source
70 revision with <tt class="docutils literal">SRC</tt> substituted by that single source revision and
71 <tt class="docutils literal">ALLSRC</tt> substituted by all source revisions.</p>
72 <p>Rebase will destroy original changesets unless you use <tt class="docutils literal"><span class="pre">--keep</span></tt>.
73 It will also move your bookmarks (even if you do).</p>
74 <p>Some changesets may be dropped if they do not contribute changes
75 (e.g. merges from the destination branch).</p>
76 <p>Unlike <tt class="docutils literal">merge</tt>, rebase will do nothing if you are at the branch tip of
77 a named branch with two heads. You will need to explicitly specify source
78 and/or destination.</p>
79 <p>If you need to use a tool to automate merge/conflict decisions, you
80 can specify one with <tt class="docutils literal"><span class="pre">--tool</span></tt>, see <a class="reference external" href="topic-merge-tools.html"><tt class="docutils literal">hg help <span class="pre">merge-tools</span></tt></a>.
81 As a caveat: the tool will not be used to mediate when a file was
82 deleted, there is no hook presently available for this.</p>
83 <p>If a rebase is interrupted to manually resolve a conflict, it can be
84 continued with --continue/-c, aborted with --abort/-a, or stopped with
85 --stop.</p>
86 <div class="verbose docutils container">
87 <p>Examples:</p>
88 <ul>
89 <li><p class="first">move &quot;local changes&quot; (current commit back to branching point)
90 to the current branch tip after a pull:</p>
91 <pre class="literal-block">
92 hg rebase
93 </pre>
94 </li>
95 <li><p class="first">move a single changeset to the stable branch:</p>
96 <pre class="literal-block">
97 hg rebase -r 5f493448 -d stable
98 </pre>
99 </li>
100 <li><p class="first">splice a commit and all its descendants onto another part of history:</p>
101 <pre class="literal-block">
102 hg rebase --source c0c3 --dest 4cf9
103 </pre>
104 </li>
105 <li><p class="first">rebase everything on a branch marked by a bookmark onto the
106 default branch:</p>
107 <pre class="literal-block">
108 hg rebase --base myfeature --dest default
109 </pre>
110 </li>
111 <li><p class="first">collapse a sequence of changes into a single commit:</p>
112 <pre class="literal-block">
113 hg rebase --collapse -r 1520:1525 -d .
114 </pre>
115 </li>
116 <li><p class="first">move a named branch while preserving its name:</p>
117 <pre class="literal-block">
118 hg rebase -r &quot;branch(featureX)&quot; -d 1.3 --keepbranches
119 </pre>
120 </li>
121 <li><p class="first">stabilize orphaned changesets so history looks linear:</p>
122 <pre class="literal-block">
123 hg rebase -r 'orphan()-obsolete()' -d 'first(max((successors(max(roots(ALLSRC) &amp; ::SRC)^)-obsolete())::) + max(::((roots(ALLSRC) &amp; ::SRC)^)-obsolete()))'
124 </pre>
125 </li>
126 </ul>
127 </div>
128 <p>Configuration Options:</p>
129 <p>You can make rebase require a destination if you set the following config
130 option:</p>
131 <pre class="literal-block">
132 [commands]
133 rebase.requiredest = True
134 </pre>
135 <p>By default, rebase will close the transaction after each commit. For
136 performance purposes, you can configure rebase to use a single transaction
137 across the entire rebase. WARNING: This setting introduces a significant
138 risk of losing the work you've done in a rebase if the rebase aborts
139 unexpectedly:</p>
140 <pre class="literal-block">
141 [rebase]
142 singletransaction = True
143 </pre>
144 <p>By default, rebase writes to the working copy, but you can configure it to
145 run in-memory for better performance. When the rebase is not moving the
146 parent(s) of the working copy (AKA the &quot;currently checked out changesets&quot;),
147 this may also allow it to run even if the working copy is dirty:</p>
148 <pre class="literal-block">
149 [rebase]
150 experimental.inmemory = True
151 </pre>
152 <p>Return Values:</p>
153 <p>Returns 0 on success, 1 if nothing to rebase or there are
154 unresolved conflicts.</p>
155 <p>Options:</p>
156 <table class="docutils option-list" frame="void" rules="none">
157 <col class="option" />
158 <col class="description" />
159 <tbody valign="top">
160 <tr><td class="option-group" colspan="2">
161 <kbd><span class="option">-s</span>, <span class="option">--source <var>&lt;REV[+]&gt;</var></span></kbd></td>
162 </tr>
163 <tr><td>&nbsp;</td><td>rebase the specified changesets and their descendants</td></tr>
164 <tr><td class="option-group" colspan="2">
165 <kbd><span class="option">-b</span>, <span class="option">--base <var>&lt;REV[+]&gt;</var></span></kbd></td>
166 </tr>
167 <tr><td>&nbsp;</td><td>rebase everything from branching point of specified changeset</td></tr>
168 <tr><td class="option-group" colspan="2">
169 <kbd><span class="option">-r</span>, <span class="option">--rev <var>&lt;REV[+]&gt;</var></span></kbd></td>
170 </tr>
171 <tr><td>&nbsp;</td><td>rebase these revisions</td></tr>
172 <tr><td class="option-group" colspan="2">
173 <kbd><span class="option">-d</span>, <span class="option">--dest <var>&lt;REV&gt;</var></span></kbd></td>
174 </tr>
175 <tr><td>&nbsp;</td><td>rebase onto the specified changeset</td></tr>
176 <tr><td class="option-group">
177 <kbd><span class="option">--collapse</span></kbd></td>
178 <td>collapse the rebased changesets</td></tr>
179 <tr><td class="option-group" colspan="2">
180 <kbd><span class="option">-m</span>, <span class="option">--message <var>&lt;TEXT&gt;</var></span></kbd></td>
181 </tr>
182 <tr><td>&nbsp;</td><td>use text as collapse commit message</td></tr>
183 <tr><td class="option-group">
184 <kbd><span class="option">-e</span>, <span class="option">--edit</span></kbd></td>
185 <td>invoke editor on commit messages</td></tr>
186 <tr><td class="option-group" colspan="2">
187 <kbd><span class="option">-l</span>, <span class="option">--logfile <var>&lt;FILE&gt;</var></span></kbd></td>
188 </tr>
189 <tr><td>&nbsp;</td><td>read collapse commit message from file</td></tr>
190 <tr><td class="option-group">
191 <kbd><span class="option">-k</span>, <span class="option">--keep</span></kbd></td>
192 <td>keep original changesets</td></tr>
193 <tr><td class="option-group">
194 <kbd><span class="option">--keepbranches</span></kbd></td>
195 <td>keep original branch names</td></tr>
196 <tr><td class="option-group">
197 <kbd><span class="option">-D</span>, <span class="option">--detach</span></kbd></td>
198 <td>(DEPRECATED)</td></tr>
199 <tr><td class="option-group" colspan="2">
200 <kbd><span class="option">-i</span>, <span class="option">--interactive</span></kbd></td>
201 </tr>
202 <tr><td>&nbsp;</td><td>(DEPRECATED)</td></tr>
203 <tr><td class="option-group" colspan="2">
204 <kbd><span class="option">-t</span>, <span class="option">--tool <var>&lt;VALUE&gt;</var></span></kbd></td>
205 </tr>
206 <tr><td>&nbsp;</td><td>specify merge tool</td></tr>
207 <tr><td class="option-group">
208 <kbd><span class="option">--stop</span></kbd></td>
209 <td>stop interrupted rebase</td></tr>
210 <tr><td class="option-group">
211 <kbd><span class="option">-c</span>, <span class="option">--continue</span></kbd></td>
212 <td>continue an interrupted rebase</td></tr>
213 <tr><td class="option-group">
214 <kbd><span class="option">-a</span>, <span class="option">--abort</span></kbd></td>
215 <td>abort an interrupted rebase</td></tr>
216 <tr><td class="option-group" colspan="2">
217 <kbd><span class="option">--auto-orphans <var>&lt;VALUE&gt;</var></span></kbd></td>
218 </tr>
219 <tr><td>&nbsp;</td><td>automatically rebase orphan revisions in the specified revset (EXPERIMENTAL)</td></tr>
220 <tr><td class="option-group">
221 <kbd><span class="option">-n</span>, <span class="option">--dry-run</span></kbd></td>
222 <td>do not perform actions, just print output</td></tr>
223 <tr><td class="option-group" colspan="2">
224 <kbd><span class="option">-T</span>, <span class="option">--template <var>&lt;TEMPLATE&gt;</var></span></kbd></td>
225 </tr>
226 <tr><td>&nbsp;</td><td>display with template</td></tr>
227 <tr><td class="option-group">
228 <kbd><span class="option">--confirm</span></kbd></td>
229 <td>ask before applying actions</td></tr>
230 </tbody>
231 </table>
232 <p>[+] marked option can be specified multiple times</p>
233 </div>
234 </div>
235 </div>
236 </div>
237 </body>
238 </html>