Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mercurial -- "merge" by abandoning one changeset

Tags:

I have two heads, let's call them "A" (the good head) and "B" (the bad head). I want to merge them by taking everything from A and nothing from B. Basically, my merge of A and B is A.

When I try hg merge, it starts asking me about this file and that, and inevitably I get into trouble. I don't want any of that! How can I tell it to merge them and end up with A, preferably without any intermediate steps?

like image 482
William Jockusch Avatar asked Dec 06 '10 23:12

William Jockusch


People also ask

How do you combine two mercurial heads?

To start a merge between the two heads, we use the hg merge command. We resolve the contents of hello. c This updates the working directory so that it contains changes from both heads, which is reflected in both the output of hg parents and the contents of hello.

How do you revert a merge in Heartgold?

To check out earlier revisions, you should use hg update REV. To cancel an uncommitted merge (and lose your changes), use hg merge --abort. With no revision specified, revert the specified files or directories to the contents they had in the parent of the working directory.

How do you use hg backout?

To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.


1 Answers

From the Mercurial tips at section 22. Keep "My" or "Their" files when doing a merge.

  • https://www.mercurial-scm.org/wiki/TipsAndTricks

Occasionally you want to merge two heads, but you want to throw away all changes from one of the heads, a so-called dummy merge. You can override the merge by using the ui.merge configuration entry:

$ hg --config ui.merge=internal:local merge  #keep my files $ hg --config ui.merge=internal:other merge  #keep their files 

Here local means parent of working directory, other is the head you want to merge with. This will leave out updates from the other head.

To merge X into the current revision without letting any of the changes from X come through, do:

hg --config ui.merge=internal:fail merge X hg revert --all --rev . 

The other approach is mentioned in : https://www.mercurial-scm.org/wiki/PruningDeadBranches

$ hg update -C tip # jump to one head $ hg merge otherhead # merge in the other head $ hg revert -a -r tip # undo all the changes from the merge $ hg commit -m "eliminate other head" # create new tip identical to the old 
like image 85
pyfunc Avatar answered Sep 20 '22 16:09

pyfunc