Is it possible to merge a range of revisions from one branch to another in Mercurial?
e.g.
|r1
|r2
|r3
|\___
| | r5
| | r6
| | r7
| | ...
| | r40
|r41
If I want to merge revisions 6 & 7, but not 5, into the main branch - is this possible?
Such a merge can be trivial, for example, if r5 modified files that are not modified in 6 & 7 (and so its changes, if not needed, can safely be ignored)
What about multiple selected revision ranges from branch A to branch B? e.g. merge 4-7, 20-25 and 30-34?
(this isn't a real case, just an illustration. I'm trying to understand if hg has this revision-range merge feature that I know svn has)
Check out the Transplant extension for mercurial, I think it will do exactly what you want.
https://www.mercurial-scm.org/wiki/TransplantExtension
The simple answer is no.
This is contrary to the spirit of Mercurial.
Your graph implies that 6
depends upon 5
so anything that pulls 6
should pull 5
also otherwise it makes no sense.
It seems to me that you got Mercurial wrong here. If your change tree is linear, it's usually a sign that you are using Mercurial like you would use CVS or SVN.
Your change tree should look more like:
4
/ \
/| |\
/ | | \
5 7 23 \
| | | 25
6 8 24 |
26
And then you could pull either the branch starting at 5
or the one starting at 23
.
Now, mistake is human, so there is a "facility" called export, which allow you to create a simple diff file from one changeset.
In your specific case, you would thus:
r4
r6
and one from r7
(export)r41
If you wish, you can also go the extension road. There are several useful extensions for manipulating the changesets. A sample set:
Here you could for example clone the repository (important, always test these on clones, just in case) and then collapse the ranges you are interested in. Then you can export/import them.
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