Search code examples
mercurialvisualhg

How to create a new "stable" branch in Mercurial


I use Mercurial (with VisualHg) for my source code and I have the following situation.

I'm currently using the default branch and would like to follow the procedure shown at http://stevelosh.com/blog/2010/05/mercurial-workflows-stable-default/ to create a new stable branch.

Here are my questions:

  1. I have created a release, tagged it and then I would like to move it to the stable branch (which currently doesn't exist). How can I do that?
  2. One I have that new branch how do I create two folders on my machine so that one contains the default and the other the stable data?

I'm not sure if this approach works properly with Mercurial: I used to use VisualSVN. Thanks.


Solution

  • To create a stable branch using VisualHg follow the following steps:

    1. Click the Update to Revision button in Visual Studio
    2. In the Update to: drop down, select your tag and then press Update
    3. Click the Commit button in Visual Studio
    4. Click on the Branch: default button above the commit message
    5. Select Open a new named branch, type in stable into the box next to it and press Ok
    6. Type in a relevant message - perhaps "Create stable branch"
    7. Press the Commit button and confirm that you want to create the new branch.

    This has created your stable branch and it has the contents of your release except that the tag that you created is still on the default branch. If you want to move it, you can do that from the workbench as follows:

    1. Click on Repo Browser button in Visual Studio
    2. Right click on the last revision on stable and click on Tag... on the pop up menu
    3. Select your tag from the drop down list
    4. Expand the options section and check Replace existing tag (-f/--force)
    5. Click Move followed by Close

    If you are working with a central repository then you'll need to specify that you want to push the new branch by clicking on the Options button of the TortoiseHg Sync window and ticking the Allow push of a new branch (--new-branch) before you push the change.

    In the future, you would merge from default to stable and then tag stable when you want to make another release. To merge changes from default into stable do the following:

    1. Click on Repo Browser button in Visual Studio
    2. Find the latest change in stable, right click and then click Update...
    3. Find the latest change in default, right click then click Merge with local...
    4. Click Next
    5. The next page might tell you that you need to resolve conflicts - to do that click on the blue underlined resolved and resolve the conflicts in the pop up dialog by selecting the conflict in the top box and pressing the desired button on the right.
    6. The next page should say "No merge conflicts, ready to commit" - click Next
    7. Accept the default message or overwrite with your own and press Commit Now
    8. Press Finish

    To merge the other way, update to default in step one and merge from stable in step 3.

    To have two folders on your machine for one to contain default and the other stable, you would simply clone the repository a second time and keep one updated to the default branch and the other updated to the stable branch.