| 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>histedit</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="histedit"> |
| 12 |
<span id="ext-histedit"></span> |
| 13 |
<h1 class="title">histedit</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><ul> |
| 19 |
<li><a class="reference internal" href="#config" id="toc-entry-2">Config</a></li> |
| 20 |
</ul> |
| 21 |
</li> |
| 22 |
<li><a class="reference internal" href="#commands" id="toc-entry-3">Commands</a><ul> |
| 23 |
<li><a class="reference internal" href="#change-manipulation" id="toc-entry-4">Change manipulation</a></li> |
| 24 |
</ul> |
| 25 |
</li> |
| 26 |
</ul> |
| 27 |
</div> |
| 28 |
<p>interactive history editing</p> |
| 29 |
<div class="section" id="description"> |
| 30 |
<h1><a class="toc-backref" href="#contents">Description</a></h1> |
| 31 |
<p>With this extension installed, Mercurial gains one new command: histedit. Usage |
| 32 |
is as follows, assuming the following history:</p> |
| 33 |
<pre class="literal-block"> |
| 34 |
@ 3[tip] 7c2fd3b9020c 2009-04-27 18:04 -0500 durin42 |
| 35 |
| Add delta |
| 36 |
| |
| 37 |
o 2 030b686bedc4 2009-04-27 18:04 -0500 durin42 |
| 38 |
| Add gamma |
| 39 |
| |
| 40 |
o 1 c561b4e977df 2009-04-27 18:04 -0500 durin42 |
| 41 |
| Add beta |
| 42 |
| |
| 43 |
o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 |
| 44 |
Add alpha |
| 45 |
</pre> |
| 46 |
<p>If you were to run <tt class="docutils literal">hg histedit c561b4e977df</tt>, you would see the following |
| 47 |
file open in your editor:</p> |
| 48 |
<pre class="literal-block"> |
| 49 |
pick c561b4e977df Add beta |
| 50 |
pick 030b686bedc4 Add gamma |
| 51 |
pick 7c2fd3b9020c Add delta |
| 52 |
|
| 53 |
# Edit history between c561b4e977df and 7c2fd3b9020c |
| 54 |
# |
| 55 |
# Commits are listed from least to most recent |
| 56 |
# |
| 57 |
# Commands: |
| 58 |
# p, pick = use commit |
| 59 |
# e, edit = use commit, but allow edits before making new commit |
| 60 |
# f, fold = use commit, but combine it with the one above |
| 61 |
# r, roll = like fold, but discard this commit's description and date |
| 62 |
# d, drop = remove commit from history |
| 63 |
# m, mess = edit commit message without changing commit content |
| 64 |
# b, base = checkout changeset and apply further changesets from there |
| 65 |
# |
| 66 |
</pre> |
| 67 |
<p>In this file, lines beginning with <tt class="docutils literal">#</tt> are ignored. You must specify a rule |
| 68 |
for each revision in your history. For example, if you had meant to add gamma |
| 69 |
before beta, and then wanted to add delta in the same revision as beta, you |
| 70 |
would reorganize the file to look like this:</p> |
| 71 |
<pre class="literal-block"> |
| 72 |
pick 030b686bedc4 Add gamma |
| 73 |
pick c561b4e977df Add beta |
| 74 |
fold 7c2fd3b9020c Add delta |
| 75 |
|
| 76 |
# Edit history between c561b4e977df and 7c2fd3b9020c |
| 77 |
# |
| 78 |
# Commits are listed from least to most recent |
| 79 |
# |
| 80 |
# Commands: |
| 81 |
# p, pick = use commit |
| 82 |
# e, edit = use commit, but allow edits before making new commit |
| 83 |
# f, fold = use commit, but combine it with the one above |
| 84 |
# r, roll = like fold, but discard this commit's description and date |
| 85 |
# d, drop = remove commit from history |
| 86 |
# m, mess = edit commit message without changing commit content |
| 87 |
# b, base = checkout changeset and apply further changesets from there |
| 88 |
# |
| 89 |
</pre> |
| 90 |
<p>At which point you close the editor and <tt class="docutils literal">histedit</tt> starts working. When you |
| 91 |
specify a <tt class="docutils literal">fold</tt> operation, <tt class="docutils literal">histedit</tt> will open an editor when it folds |
| 92 |
those revisions together, offering you a chance to clean up the commit message:</p> |
| 93 |
<pre class="literal-block"> |
| 94 |
Add beta |
| 95 |
*** |
| 96 |
Add delta |
| 97 |
</pre> |
| 98 |
<p>Edit the commit message to your liking, then close the editor. The date used |
| 99 |
for the commit will be the later of the two commits' dates. For this example, |
| 100 |
let's assume that the commit message was changed to <tt class="docutils literal">Add beta and delta.</tt> |
| 101 |
After histedit has run and had a chance to remove any old or temporary |
| 102 |
revisions it needed, the history looks like this:</p> |
| 103 |
<pre class="literal-block"> |
| 104 |
@ 2[tip] 989b4d060121 2009-04-27 18:04 -0500 durin42 |
| 105 |
| Add beta and delta. |
| 106 |
| |
| 107 |
o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 |
| 108 |
| Add gamma |
| 109 |
| |
| 110 |
o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 |
| 111 |
Add alpha |
| 112 |
</pre> |
| 113 |
<p>Note that <tt class="docutils literal">histedit</tt> does <em>not</em> remove any revisions (even its own temporary |
| 114 |
ones) until after it has completed all the editing operations, so it will |
| 115 |
probably perform several strip operations when it's done. For the above example, |
| 116 |
it had to run strip twice. Strip can be slow depending on a variety of factors, |
| 117 |
so you might need to be a little patient. You can choose to keep the original |
| 118 |
revisions by passing the <tt class="docutils literal"><span class="pre">--keep</span></tt> flag.</p> |
| 119 |
<p>The <tt class="docutils literal">edit</tt> operation will drop you back to a command prompt, |
| 120 |
allowing you to edit files freely, or even use <tt class="docutils literal">hg record</tt> to commit |
| 121 |
some changes as a separate commit. When you're done, any remaining |
| 122 |
uncommitted changes will be committed as well. When done, run <tt class="docutils literal">hg |
| 123 |
histedit <span class="pre">--continue</span></tt> to finish this step. If there are uncommitted |
| 124 |
changes, you'll be prompted for a new commit message, but the default |
| 125 |
commit message will be the original message for the <tt class="docutils literal">edit</tt> ed |
| 126 |
revision, and the date of the original commit will be preserved.</p> |
| 127 |
<p>The <tt class="docutils literal">message</tt> operation will give you a chance to revise a commit |
| 128 |
message without changing the contents. It's a shortcut for doing |
| 129 |
<tt class="docutils literal">edit</tt> immediately followed by <cite>hg histedit --continue`</cite>.</p> |
| 130 |
<p>If <tt class="docutils literal">histedit</tt> encounters a conflict when moving a revision (while |
| 131 |
handling <tt class="docutils literal">pick</tt> or <tt class="docutils literal">fold</tt>), it'll stop in a similar manner to |
| 132 |
<tt class="docutils literal">edit</tt> with the difference that it won't prompt you for a commit |
| 133 |
message when done. If you decide at this point that you don't like how |
| 134 |
much work it will be to rearrange history, or that you made a mistake, |
| 135 |
you can use <tt class="docutils literal">hg histedit <span class="pre">--abort</span></tt> to abandon the new changes you |
| 136 |
have made and return to the state before you attempted to edit your |
| 137 |
history.</p> |
| 138 |
<p>If we clone the histedit-ed example repository above and add four more |
| 139 |
changes, such that we have the following history:</p> |
| 140 |
<pre class="literal-block"> |
| 141 |
@ 6[tip] 038383181893 2009-04-27 18:04 -0500 stefan |
| 142 |
| Add theta |
| 143 |
| |
| 144 |
o 5 140988835471 2009-04-27 18:04 -0500 stefan |
| 145 |
| Add eta |
| 146 |
| |
| 147 |
o 4 122930637314 2009-04-27 18:04 -0500 stefan |
| 148 |
| Add zeta |
| 149 |
| |
| 150 |
o 3 836302820282 2009-04-27 18:04 -0500 stefan |
| 151 |
| Add epsilon |
| 152 |
| |
| 153 |
o 2 989b4d060121 2009-04-27 18:04 -0500 durin42 |
| 154 |
| Add beta and delta. |
| 155 |
| |
| 156 |
o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 |
| 157 |
| Add gamma |
| 158 |
| |
| 159 |
o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 |
| 160 |
Add alpha |
| 161 |
</pre> |
| 162 |
<p>If you run <tt class="docutils literal">hg histedit <span class="pre">--outgoing</span></tt> on the clone then it is the same |
| 163 |
as running <tt class="docutils literal">hg histedit 836302820282</tt>. If you need plan to push to a |
| 164 |
repository that Mercurial does not detect to be related to the source |
| 165 |
repo, you can add a <tt class="docutils literal"><span class="pre">--force</span></tt> option.</p> |
| 166 |
<div class="section" id="config"> |
| 167 |
<h2><a class="toc-backref" href="#contents">Config</a></h2> |
| 168 |
<p>Histedit rule lines are truncated to 80 characters by default. You |
| 169 |
can customize this behavior by setting a different length in your |
| 170 |
configuration file:</p> |
| 171 |
<pre class="literal-block"> |
| 172 |
[histedit] |
| 173 |
linelen = 120 # truncate rule lines at 120 characters |
| 174 |
</pre> |
| 175 |
<p>The summary of a change can be customized as well:</p> |
| 176 |
<pre class="literal-block"> |
| 177 |
[histedit] |
| 178 |
summary-template = '{rev} {bookmarks} {desc|firstline}' |
| 179 |
</pre> |
| 180 |
<p>The customized summary should be kept short enough that rule lines |
| 181 |
will fit in the configured line length. See above if that requires |
| 182 |
customization.</p> |
| 183 |
<p><tt class="docutils literal">hg histedit</tt> attempts to automatically choose an appropriate base |
| 184 |
revision to use. To change which base revision is used, define a |
| 185 |
revset in your configuration file:</p> |
| 186 |
<pre class="literal-block"> |
| 187 |
[histedit] |
| 188 |
defaultrev = only(.) & draft() |
| 189 |
</pre> |
| 190 |
<p>By default each edited revision needs to be present in histedit commands. |
| 191 |
To remove revision you need to use <tt class="docutils literal">drop</tt> operation. You can configure |
| 192 |
the drop to be implicit for missing commits by adding:</p> |
| 193 |
<pre class="literal-block"> |
| 194 |
[histedit] |
| 195 |
dropmissing = True |
| 196 |
</pre> |
| 197 |
<p>By default, histedit will close the transaction after each action. For |
| 198 |
performance purposes, you can configure histedit to use a single transaction |
| 199 |
across the entire histedit. WARNING: This setting introduces a significant risk |
| 200 |
of losing the work you've done in a histedit if the histedit aborts |
| 201 |
unexpectedly:</p> |
| 202 |
<pre class="literal-block"> |
| 203 |
[histedit] |
| 204 |
singletransaction = True |
| 205 |
</pre> |
| 206 |
</div> |
| 207 |
</div> |
| 208 |
<div class="section" id="commands"> |
| 209 |
<h1><a class="toc-backref" href="#contents">Commands</a></h1> |
| 210 |
<div class="section" id="change-manipulation"> |
| 211 |
<h2><a class="toc-backref" href="#contents">Change manipulation</a></h2> |
| 212 |
<div class="section" id="histedit-1"> |
| 213 |
<h3>histedit</h3> |
| 214 |
<p>interactively edit changeset history:</p> |
| 215 |
<pre class="literal-block"> |
| 216 |
hg histedit [OPTIONS] ([ANCESTOR] | --outgoing [URL]) |
| 217 |
</pre> |
| 218 |
<p>This command lets you edit a linear series of changesets (up to |
| 219 |
and including the working directory, which should be clean). |
| 220 |
You can:</p> |
| 221 |
<ul class="simple"> |
| 222 |
<li><cite>pick</cite> to [re]order a changeset</li> |
| 223 |
<li><cite>drop</cite> to omit changeset</li> |
| 224 |
<li><cite>mess</cite> to reword the changeset commit message</li> |
| 225 |
<li><cite>fold</cite> to combine it with the preceding changeset (using the later date)</li> |
| 226 |
<li><cite>roll</cite> like fold, but discarding this commit's description and date</li> |
| 227 |
<li><cite>edit</cite> to edit this changeset (preserving date)</li> |
| 228 |
<li><cite>base</cite> to checkout changeset and apply further changesets from there</li> |
| 229 |
</ul> |
| 230 |
<p>There are a number of ways to select the root changeset:</p> |
| 231 |
<ul class="simple"> |
| 232 |
<li>Specify ANCESTOR directly</li> |
| 233 |
<li>Use --outgoing -- it will be the first linear changeset not |
| 234 |
included in destination. (See <a class="reference external" href="hgrc.5.html#paths"><tt class="docutils literal">hg help <span class="pre">config.paths.default-push</span></tt></a>)</li> |
| 235 |
<li>Otherwise, the value from the "histedit.defaultrev" config option |
| 236 |
is used as a revset to select the base revision when ANCESTOR is not |
| 237 |
specified. The first revision returned by the revset is used. By |
| 238 |
default, this selects the editable history that is unique to the |
| 239 |
ancestry of the working directory.</li> |
| 240 |
</ul> |
| 241 |
<div class="verbose docutils container"> |
| 242 |
<p>If you use --outgoing, this command will abort if there are ambiguous |
| 243 |
outgoing revisions. For example, if there are multiple branches |
| 244 |
containing outgoing revisions.</p> |
| 245 |
<p>Use "min(outgoing() and ::.)" or similar revset specification |
| 246 |
instead of --outgoing to specify edit target revision exactly in |
| 247 |
such ambiguous situation. See <a class="reference external" href="hg.1.html#revsets"><tt class="docutils literal">hg help revsets</tt></a> for detail about |
| 248 |
selecting revisions.</p> |
| 249 |
</div> |
| 250 |
<div class="verbose docutils container"> |
| 251 |
<p>Examples:</p> |
| 252 |
<blockquote> |
| 253 |
<ul> |
| 254 |
<li><p class="first">A number of changes have been made. |
| 255 |
Revision 3 is no longer needed.</p> |
| 256 |
<p>Start history editing from revision 3:</p> |
| 257 |
<pre class="literal-block"> |
| 258 |
hg histedit -r 3 |
| 259 |
</pre> |
| 260 |
<p>An editor opens, containing the list of revisions, |
| 261 |
with specific actions specified:</p> |
| 262 |
<pre class="literal-block"> |
| 263 |
pick 5339bf82f0ca 3 Zworgle the foobar |
| 264 |
pick 8ef592ce7cc4 4 Bedazzle the zerlog |
| 265 |
pick 0a9639fcda9d 5 Morgify the cromulancy |
| 266 |
</pre> |
| 267 |
<p>Additional information about the possible actions |
| 268 |
to take appears below the list of revisions.</p> |
| 269 |
<p>To remove revision 3 from the history, |
| 270 |
its action (at the beginning of the relevant line) |
| 271 |
is changed to 'drop':</p> |
| 272 |
<pre class="literal-block"> |
| 273 |
drop 5339bf82f0ca 3 Zworgle the foobar |
| 274 |
pick 8ef592ce7cc4 4 Bedazzle the zerlog |
| 275 |
pick 0a9639fcda9d 5 Morgify the cromulancy |
| 276 |
</pre> |
| 277 |
</li> |
| 278 |
<li><p class="first">A number of changes have been made. |
| 279 |
Revision 2 and 4 need to be swapped.</p> |
| 280 |
<p>Start history editing from revision 2:</p> |
| 281 |
<pre class="literal-block"> |
| 282 |
hg histedit -r 2 |
| 283 |
</pre> |
| 284 |
<p>An editor opens, containing the list of revisions, |
| 285 |
with specific actions specified:</p> |
| 286 |
<pre class="literal-block"> |
| 287 |
pick 252a1af424ad 2 Blorb a morgwazzle |
| 288 |
pick 5339bf82f0ca 3 Zworgle the foobar |
| 289 |
pick 8ef592ce7cc4 4 Bedazzle the zerlog |
| 290 |
</pre> |
| 291 |
<p>To swap revision 2 and 4, its lines are swapped |
| 292 |
in the editor:</p> |
| 293 |
<pre class="literal-block"> |
| 294 |
pick 8ef592ce7cc4 4 Bedazzle the zerlog |
| 295 |
pick 5339bf82f0ca 3 Zworgle the foobar |
| 296 |
pick 252a1af424ad 2 Blorb a morgwazzle |
| 297 |
</pre> |
| 298 |
</li> |
| 299 |
</ul> |
| 300 |
</blockquote> |
| 301 |
</div> |
| 302 |
<p>Returns 0 on success, 1 if user intervention is required (not only |
| 303 |
for intentional "edit" command, but also for resolving unexpected |
| 304 |
conflicts).</p> |
| 305 |
<p>Options:</p> |
| 306 |
<table class="docutils option-list" frame="void" rules="none"> |
| 307 |
<col class="option" /> |
| 308 |
<col class="description" /> |
| 309 |
<tbody valign="top"> |
| 310 |
<tr><td class="option-group" colspan="2"> |
| 311 |
<kbd><span class="option">--commands <var><FILE></var></span></kbd></td> |
| 312 |
</tr> |
| 313 |
<tr><td> </td><td>read history edits from the specified file</td></tr> |
| 314 |
<tr><td class="option-group"> |
| 315 |
<kbd><span class="option">-c</span>, <span class="option">--continue</span></kbd></td> |
| 316 |
<td>continue an edit already in progress</td></tr> |
| 317 |
<tr><td class="option-group"> |
| 318 |
<kbd><span class="option">--edit-plan</span></kbd></td> |
| 319 |
<td>edit remaining actions list</td></tr> |
| 320 |
<tr><td class="option-group"> |
| 321 |
<kbd><span class="option">-k</span>, <span class="option">--keep</span></kbd></td> |
| 322 |
<td>don't strip old nodes after edit is complete</td></tr> |
| 323 |
<tr><td class="option-group"> |
| 324 |
<kbd><span class="option">--abort</span></kbd></td> |
| 325 |
<td>abort an edit in progress</td></tr> |
| 326 |
<tr><td class="option-group"> |
| 327 |
<kbd><span class="option">-o</span>, <span class="option">--outgoing</span></kbd></td> |
| 328 |
<td>changesets not found in destination</td></tr> |
| 329 |
<tr><td class="option-group"> |
| 330 |
<kbd><span class="option">-f</span>, <span class="option">--force</span></kbd></td> |
| 331 |
<td>force outgoing even for unrelated repositories</td></tr> |
| 332 |
<tr><td class="option-group" colspan="2"> |
| 333 |
<kbd><span class="option">-r</span>, <span class="option">--rev <var><REV[+]></var></span></kbd></td> |
| 334 |
</tr> |
| 335 |
<tr><td> </td><td>first revision to be edited</td></tr> |
| 336 |
<tr><td class="option-group" colspan="2"> |
| 337 |
<kbd><span class="option">-T</span>, <span class="option">--template <var><TEMPLATE></var></span></kbd></td> |
| 338 |
</tr> |
| 339 |
<tr><td> </td><td>display with template</td></tr> |
| 340 |
</tbody> |
| 341 |
</table> |
| 342 |
<p>[+] marked option can be specified multiple times</p> |
| 343 |
</div> |
| 344 |
</div> |
| 345 |
</div> |
| 346 |
</div> |
| 347 |
</body> |
| 348 |
</html> |