i have these two named branches in my repo. Stable and dev. My question is how do i copy a bugfix patch that was changed in stable to the dev branch? i would really like to do this within the framework and not with any extension :)
EDIT
I set a bounty for the question because i really wanted the solution. There was a nice solution but was left mid way. So i had no other option. It now appears to have been answered. But i will let the question fair another day, just in case someone has a better solution. Hope that makes sense. :)
To augment Tim's answer, a different way to approach it is how the Mercurial recommend you do it if you can, plan ahead (I'll see if I can rustle up a link.)
The plan goes that if you know that a bugfix/change has to go into several branches, you don't commit that changeset into one of those places to begin with, you do it somewhere else.
Since you're fixing a bug, somewhere in the history of the project, that bug was introduced.
And since the bugfix needs to go into more than one branch, that "somewhere" has to be before the point where you branched, otherwise the bug wouldn't be in both (/all) branches.
So, the recommended way is to fix the bug where it was introduced, and then merge that changeset into each of the branches that needs it.
Let's look at an example, we have default
and stable
branches:
1---2---3---4---5---6---7---8---9---10 default
\ \
\ \
11--------------12--13 stable
Then you discover that changeset 2 introduced a bug, and the bugfix needs to be applied to both default
and stable
. The way you describe it in the question, it looks like you would 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 would merge changeset 13 into default
as well. If you don't want that to happen, you would instead 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 bugfixing-scenarios, the 9th Chapter of 'Mercurial: The Definitive Guide' is well worth the read.
If your dev
branch is a descendant of your "stable named branch", then you could simply
hg update dev
hg merge stable
If this is not feasible, then the most natural answer is the transplant
extension. This extension is distributed with Mercurial, so you only need to add a single line to your mercurial.ini
or .hgrc
to enable it. With it enabled, you can:
hg update dev
hg transplant --log <rev>
If you really want to avoid using an extension, then you could use export
and import
:
hg export --rev <rev> > tmp.patch
hg update dev
hg import tmp.patch
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