Tonfa is right. What you describe does not “merge” (or “push” or “pull”); it's a cherry pick. Push or pull push all changes from one repo to another that are not already in this repo. A "merger" takes two "heads" and combines them into a new set of changes, which is a combination of both.
If you really need to move G, but you cannot leave D, E, F, you need to “hg export” G from repo A and then “hg import” to repo A. Transplant extension is a wrapper around export / import with some subtleties to avoid moving the same set of changes multiple times.
However , the drawback of using import / export, transplantation and cherry picking in general is that you cannot move through G without your ancestors, because in Mercurial, the name of the change set is its "hash", which includes the hashes of your parents. Different parents (G the new parent will be C, not F) means a different hashid, so it is no longer G - this is G's job, but a new set of changes by name.
Moving around G as something new, let him name G '(Gee prime), for some purposes it does not really matter, but for others it is a big pita. When repo B receives a new set of changes soon, H, and you want to move it over your parent, will change from G to G ', which have different hashes. This means that H will move as H '- 100 changes the rowset down, and you will have different hashes for everything, because you could not stand D, E, F in repo A.
Things will get even more out of impact if / when you want to move material from Repo A to Repo B (the opposite direction of your previous move). If you try to do a simple "hg push" from A to B, you will get G '(and H' and subsequent descendants) that will be duplicated by the change sets that you already have in Repo B.
Well, your options?
- Does not care. Your data is still there, you just get the same commands with different names and work more on future exchanges between the two repositories. It's not like that, just a little clumsy, and some people don't care.
- Move all D, E, and F to Repo A. You can move all changes if they are harmless and avoid all problems. If they are not so harmless, you can move them and then do an “hg backout” to undo the effects of D, E and F in the new change set H.
- Give G the best source code to get started. This means that I have to mention it, because it is too late to go along this route (without editing history ). What you had to do before working on the G
hg update C was hg update C If G does not rely or does not need sets of changes D, E and F, then this should not be their child.
If instead you upgrade to C first, you will have a graph like this:
A - B - C - D - E - F \ G
then the whole answer to this question will be just hg push -r G ../repoA , and G will move cleanly, keeping the same hash, and D, E and F will not go with it.
UPDATE:
As stated in the comments. With modern Mercurials, the hg graft team is the perfect way to do this.