How to make cherry - choose one revision in Mercurial?

In Mercurial / TortoiseHg below, the easiest way to combine revision “G” into repo A is without accepting D, E, or F (suppose G doesn't have a dependency on D, E, or F).

Repo A: A - B - C Repo B (Clone of A) A - B - C - D - E - F - G 

Is a patch better?

+66
mercurial cherry-pick tortoisehg
Nov 03 '09 at 20:54
source share
2 answers

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.

+74
Nov 04 '09 at 4:32
source share

Referring to the heading, which examines the selection of cherries in general, I will give an example of working in one repo, as Internet search engines can attract people here to collect cherries in general. Working in a single repository, this will be done using hg graft :

 hg update C hg graft G 

Result:

  G' / A - B - C - D - E - F - G 

An additional warning: two sets of changes will be considered as independent, parallel commits in the same files and can lead to merge conflicts, therefore, in general, to control branches, you should avoid choosing cherries. For example, if G is a bug fix applied to a stable version branch marked as 1.0.1 , you should rather merge the freeze branch with it and merge the master branch with freeze from time to time.

+33
Mar 31 '14 at 13:19
source share



All Articles