Partial merge (or maybe cherry picking)?
Benjamin Pollack
benjamin at bitquabit.com
Wed Mar 4 12:02:14 CST 2009
On 3/4/09 11:46 AM, Frank Hu wrote:
> I don't know if "partial merge" is the right term to describe my
> problem. I have a project, say with source files a.c, b.c and c.c,
> and I branched out to try some new features, mostly modifying a.c and
> b.c. So I have the default branch and the feature branch (named
> branch in the repo). At some point, I found a bug in c.c,say at
> revision 10, and fixed it. Now I'd like the default branch to have
> the fixed c.c too. Is there an easy way to do that? I don't want to
> merge the two branches, because a.c and b.c are significantly
> different between the two branches. I guess I could do an update and
> a revert in the default branch, but is there anything else I can do?
>
There are two things you can do:
1. Apply the fix to the point in history where you introduced the bug,
then merge that commit into both branches separately. Assuming
that your fixing commit were revision 11, the command would be
$ hg merge -r 11
Since the bug exists in both branches, I assume that it was before
the fork, meaning that your merge should apply cleanly and only
affect c.c.
2. Use the transplant extension. Assuming that you made the fix to
c.c at revision 11, then from your default branch, you can simply
issue
$ hg transplant -b branchname 11
Note however that transplant tends to make later merges a bit messy,
since the same patch appears in two different commits. I remember
having problems with this in the past, but it may work fine now.
--Benjamin
More information about the Mercurial
mailing list