Matt Grande
Matt Grande

Reputation: 12157

Hg Branching/Merging for Bugfixes

So, I have an Hg repo that looks like this:

O [default] [tip] Current repo
|
O Merging changes from named branch
|\ 
|O Something from a named branch
||
O| [prod-v1.2] Okay, version 1.2 is done

Now I've come across a problem in version 1.2. I can update to the tag prod-v1.2 and commit it, but when pushing, it warns me about multiple heads. Is there a way I can make my new "bugfix" branch the default temporarily? How can I manage this?

Upvotes: 1

Views: 159

Answers (1)

krtek
krtek

Reputation: 26597

The best way to do this, is to create a new branch for your bugfix and then commit in it. The next time you will have to do changes on the version actually in production, you can just update to your branch and commit your change there.

If needed, you can easily merge the content of the branch to your development branch.

An example of this kind of workflow is described here : http://stevelosh.com/blog/2010/05/mercurial-workflows-stable-default/ but you can also find many more way to do this.

In your specific case, you can do something like this if you made only one commit :

 hg rollback # rollbacking last commit to allow for branch creation
 hg branch bugfix-v1.2
 hg commit
 hg push

You can now switch back to your default branch and continue to work on the next version... Next time you have a bugfix to do, just switch to your branch with hg update bugfix-v1.2 and commit here.

Upvotes: 2

Related Questions