I have a mercurial repository history that looks like this :
A -> B -> C -> N1 -> N2 -> N3 -> D -> E -> F
And I would like to transform it into the following history :
A -> B -> C -> D -> E -> F
\_ N1 -> N2 -> N3
Given that I have a clone whose history stops at C, what is the best way to proceed ? D E F changeset is not conflicting with N1 N2 N3 changeset. Well, at least I hope so ;)
No need to have a clone, you can work in the original repo. You can transplant D, E and F on top of C, creating copies D1, E1 and F1 (which will be identical to the originals, provided that there are no conflicting changes). You'll have this:
A -> B -> C -> N1 -> N2 -> N3 -> D -> E -> F
\_ D1 -> E1 -> F1
Then you can strip the originals. See the script below.
$ hg update C
$ hg transplant D E F
$ hg strip D
You'll have to enable two extensions: transplant
and mq
. To do this, add these lines to your hgrc
:
[extensions]
transplant=
mq=
Update: As of Mercurial 2.0, graft
(a built-in command) can be used instead of transplant
here; rebase, as Laurens Holst suggests, should work equally well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With