Splitting a linear story into two branches in Mercurial

I have a mercury storage history that looks like this:

A -> B -> C -> N1 -> N2 -> N3 -> D -> E -> F 

And I would like to transform it into the following story:

 A -> B -> C -> D -> E -> F \_ N1 -> N2 -> N3 

Given that I have a clone whose story dwells on C, what is the best way to move on? DEF change set does not contradict set N1 N2 N3. Well, at least I hope so;)

+4
source share
2 answers

No need to have a clone, you can work in the original repo. You can transfer D, E, and F over C, creating copies of D1, E1, and F1 (which will be identical to the originals, provided that there are no conflicting changes). You will have the following:

 A -> B -> C -> N1 -> N2 -> N3 -> D -> E -> F \_ D1 -> E1 -> F1 

Then you can delete the originals. See below script.

 $ hg update C $ hg transplant DEF $ hg strip D 

You need to enable two extensions: transplant and mq . To do this, add these lines to your hgrc :

 [extensions] transplant= mq= 

Update:. Starting with Mercurial 2.0, graft (built-in command) can be used instead of transplant ; reba, as Laurens Holst suggests , should work equally well.

+6
source

You can use rebase to do this:

 hg rebase --source D --dest C 

This works with Mercurial 2.0; He previously used complaints when reinstalling to the ancestor version, but they removed it.

You need to enable the extension for redirection if you do not already have:

 [extensions] rebase = 
+2
source

Source: https://habr.com/ru/post/1385795/


All Articles