Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial - close default branch and replace with a named branch as new default

In a mercurial repo, the "default" branch has fallen very out of date to the point where it no longer makes sense to merge in the changes from "develop", a named branch which has the latest deployed version of the application.

Instead of merging develop into default, how can I close the current default branch and then create a new default branch using the head from develop?

I've seen a few other questions and answers which are similar, perhaps the same, but I am still having trouble understanding how this should work.

Thanks!

like image 540
kgx Avatar asked Feb 20 '13 16:02

kgx


People also ask

How to switch Branches in Mercurial?

Quickly switch to another branch or bookmarkIn the Status bar, click the Mercurial Branch widget to open the Branches popup. Select the branch or bookmark to which you want to switch and in the menu that opens, click Update.

What is mercurial default branch?

Mercurial's main branch is called "default" and is analogous to "trunk" in SVN, "HEAD" in CVS, and "master" in Git. If you try to use some other name for your "main" branch, users will get a more or less random branch when they clone and commit things in the wrong place, which is generally undesirable.

How do I close a branch on Tortoisehg?

when you are on your NewFeature branch (no need to have anything to commit - or you do it with your final merge) click "Branch: NewFeature" (it's at the top in bold) select "Close current branch".


2 Answers

If default has diverged somewhat from develop and you want default to be exactly the same as develop after the merge, you need a slightly different set of commands from what Edward gave you (this will also work where develop is a direct descendant of default).

hg update -C default
hg -y merge --tool internal:fail develop
hg revert --all --no-backup -r develop
hg resolve --all --mark
hg commit -m "merge updating default to current develop"

This means that any conflicts will result in an unresolved merge. You then revert everything to be the same as on the develop branch (with no backup so you don't get lots of .orig files left over).

like image 113
Tim Delaney Avatar answered Oct 07 '22 20:10

Tim Delaney


Based on your comment that it is not a requirement to close the branch, here's a series of steps that should get the default branch in tune with the develop branch:

  1. hg update default
  2. hg merge --tool internal:other -- to merge while privileging the develop branch
  3. hg diff -r develop -- compare with develop to ensure that you have an exact copy
  4. hg commit -m "merge updating default to current develop"

Once complete, you should have an updated default that mirrors the develop branch, bringing them back into sync.

like image 33
Edward Avatar answered Oct 07 '22 18:10

Edward