Mercurial: apply bug fix from stable named branch to dev branch

I have these two branches in my repo. Stable and virgins. My question is how to copy the patch patch that was changed in the stable dev branch? I really would like to do this within the framework, and not with any extension :)

EDIT

I set a bounty for the question because I really wanted a solution. It was a good decision, but he stayed in the middle. So I had no other choice. Seems to have answered now. But I will allow this question again, in case someone has a better solution. Hope this makes sense. :)

+6
source share
3 answers

To increase Tim’s answer , another way to get closer to him is how Mercurial recommends you do it, if you can, plan ahead (I’ll see if I can rustle the link.)

The plan says that if you know that an error / change should be sent in several branches, you are not making this set of changes in one of these places to start, you are doing it somewhere else.

Since you are fixing a bug somewhere in the history of the project, this bug has been introduced.

And since you need to go to more than one branch to correct errors, it should be somewhere until the moment you branch, otherwise the error will not be in both branches (/ all).

So, the recommended way is to fix the error where it was introduced, and then merge this set of changes into each of the branches that it needs.

Let's look at an example, we have the default and stable branches:

 1---2---3---4---5---6---7---8---9---10 default \ \ \ \ 11--------------12--13 stable 

Then you will find that changeet 2 introduced the error, and the fix should apply to both default and stable . The way you describe this in the question, it looks like you will do this:

 1---2---3---4---5---6---7---8---9---10--15 default \ \ /^-- merge stable into default \ \ / 11--------------12--13----14 stable ^-- bugfix 

But this will merge changeet 13 into default . If you do not want this to happen, you must do this:

  v-- bugfix 14--------------------------+--+ / | \ / | \ 1---2---3---4---5---6---7---8---9--x-10--15 default \ \ | ^-- merge 14 into default \ \ | 11--------------12--13--16 stable ^-- merge 14 into stable 

For more information on how to use Mercurial in error correction scenarios, the 9th chapter of the Mercurial: The Definitive Guide is well worth the read.

+10
source

If your dev branch is a descendant of your "stable name branch", you can simply

 hg update dev hg merge stable 

If this is not possible, then the most natural answer is to expand the transplant . This extension is distributed with Mercurial, so you only need to add one line to mercurial.ini or .hgrc to enable it. With it, you can:

 hg update dev hg transplant --log <rev> 

If you really want to avoid using the extension, you can use export and import :

 hg export --rev <rev> > tmp.patch hg update dev hg import tmp.patch 
+5
source

Graft extension does the trick beautifully - and exactly what you want

0
source

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


All Articles