splitting apart a changeset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jun 10 13:39:56 UTC 2020


Hello there,

Sorry for not getting back to you earlier, this feel into the cracks

On 4/11/20 5:07 PM, Ernie Rael wrote:
> Given:
> 
> $ hg log -l8 -Trevsum
> 1543:fed597e360a9 draft Fix stuffReadbuff(":someCommand\n") issue, 
> required IDE restart
> 1542:8d1ea8b127b1 draft annotate source with "// DONE" for end of line 
> Segment issues
> 1541:cefdab9bbdad draft Better skipwhite(iter) implementation. 
> Misc.skipwhite tests.
> 
> I want to split 1541 into two changesets: algorithmic change and tests. 
> In this case I need to take one file (algorithm) out and into it's own 
> changeset.  I've never tried hg split, but I'm wondering if that's the 
> best/simplest way to go about it.
> 
>     hg split -r 1541 src/com/raelity/jvi/core/Misc.java
> 
> But reading the help, I'm not sure that's what I want. The statement
> 
>     The files that doesn't match will be gathered in the last changeset.

This should be exactly do what you want. By default, split will spawn a 
UI that let you select the bits you want to use for the first changeset. 
Then let you do further selection and simply "commit the rest". Make 
sure you have `ui.interface=curses` for a better UI.


You can also run `hg split -r 1541 src/com/raelity/jvi/core/Misc.java 
--no-interactive` to skip the UI. In this case, 1541 will directly be 
split into two changesets: the first will contains 
src/com/raelity/jvi/core/Misc.java, the second will contains the other 
files touched by 1541. Same as what you can achieve with the UI, but 
without having to go through the UI.

> Alternately I'm thinking about
> 
> hg up 1541
> hg amend --extract src/com/raelity/jvi/core/Misc.java
> hg commit -m 'algo change'
> hg evolve

That one will work to, but will not record that 1541 have been split in 
two in the evolution history. This can lead to less goot behavior of `hg 
evolve` and less useful information in things like `hg obslog` in the 
future.

Actually, with the sequence of command, `hg evolve` will evolve 
descendant of 1541 on the changeset resulting from the `hg amend` call. 
ignoring the `hg commit` one.

Does this help?

How could we improve `hg split` documentation so that you did not had 
doubt in the first place ?


-- 
Pierre-Yves David


More information about the Mercurial mailing list