I have two mercurial repositories, generic
and specific
, which is a clone of the first repo:
$ hg glog -R generic
@ changeset: 0:d516ded3bf0a
summary: generic project commit
$ hg glog -R specific
@ changeset: 3:5f7b2efea94b
| summary: added another specific project change
o changeset: 2:e2ad52001bcf
| summary: added generic project change (backport)
o changeset: 1:a4220a2c7a80
| summary: added specific project change
o changeset: 0:d516ded3bf0a
summary: generic project commit
Now I want to backport changeset 2 in specific
to generic
. I don't want to add changesets 1 and 3, just cs 2 (cherry-pick). It seems there are two alternatives: transplant and graft. transplant would be ok because it allows to move patches from another repository (in my case from specific
to generic
) but it's limited in merge capabilities. On the other hand, graft would provide smarter merge but doesn't support grafting from another repo (only between branches of the same).
The goal is to add only changeset 2 in specific
to generic
. This is how I proceeded, without success.
$ cd specific
$ hg up 0 # the common ancestor
$ hg branch backport-cs2
$ hg graft 2
$ hg glog
@ changeset: 4:1405acc4a121
| branch: backport-cs2
| tag: tip
| parent: 0:d516ded3bf0a
| summary: added generic project change (backport)
|
| o changeset: 3:5f7b2efea94b
| | summary: added another specific project change
| |
| o changeset: 2:e2ad52001bcf
| | summary: added generic project change (backport)
| |
| o changeset: 1:a4220a2c7a80
|/ summary: added specific project change
|
o changeset: 0:d516ded3bf0a
summary: generic project commit
So far so good. The last step is to pull the branch backport-cs2
of specific
into the default branch of generic
.
$ cd ../generic
$ hg pull -b backport-cs2 ../specific
$ hg glog
o changeset: 1:1405acc4a121
| branch: backport-cs2
| tag: tip
| summary: added generic project change (backport)
|
@ changeset: 0:d516ded3bf0a
summary: generic project commit
Now in generic
there is the changeset I want, but it's in a new branch while I'd like to have it in default. Any suggestion how to do that? Ideas for a better approach to backporting are appreciated as well.