How can I push/pull an individual changeset between repositories in Mercurial?

Daniel Magliola picture Daniel Magliola · Sep 11, 2010 · Viewed 10.4k times · Source

I have the following situation:

  • I have site A, which has it's Mercurial repo, and we've been developing it for a while. Let's say A has had 5 revisions.
  • We now has to create Site B, which is almost identical to site A, except for graphical design, mostly. So I cloned the repo, started site B, and now B's repo has all of A's history, plus a bunch of changesets that should never go back to A (mostly CSS and images). Let's say these changes took me 3 revisions.
  • Finally, I've now made a change to B that I would like to move back to A because it belongs on both sites. This is revision 9 in B's repo.

The question is: How can I move revision 9 from B's repo into A's repo, without also moving revisions 6-8?

  • I've tried regular pushing/pulling, but that moves all the changesets.
  • I've tried exporting bundles or patches, but those refuse to import in A because of the missing parent.

I thought one of the beauties of DVCS was that I could do this kind of thing easily (which in the "centralized" VCS world I could fix easily with branches and merging, I've done it with Vault a lot and it's pretty easy).

Am I missing something here?

NOTE: I looked into "MQ", but that seems to be a big can of worms, and it looks like it'll affect the regular commit cycle just for being enabled. Is this correct?

Any help or pointers will be greatly appreciated. Thank you!

Daniel

Answer

supakeen picture supakeen · Sep 11, 2010

https://www.mercurial-scm.org/wiki/wiki/TransplantExtension

See under "Using transplant to cherrypick a set of changesets":

Transplant can manage multiple changesets or changeset ranges like this:

hg transplant REV1:REV2 REV3

This example would cherrypick the range of changesets specified by REV1:REV2 and the additional changeset REV3 upon the working directory revision.

Ideally you would do this with branches though?