Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We've got a repository with two named branches in it: dev and production. There's also the default branch, which we aren't using. Unfortunately, whenever people clone the repository, it automatically puts them on default, and we're having problems because people will inadvertently commit to it.

Is there a way to delete the default branch, or disable it, or set Mercurial so that clones will automatically start on the dev branch?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

The mercurial documentation has some examples of precommit hooks and one, ironically, is checking the branch name. In the example, it checks to make sure it matches a regular expression. You could tweak it to make sure the name isn't "default".

This may not prevent the clones from starting on the "default" branch, but at least with this hook in place, no one can put any code into "default".

share|improve this answer

This answer has become outdated: you can now add a @ bookmark and Mercurial 2.4 and later will automatically check it out for a new clone. Your users will have to be careful about keeping the @ bookmark pointed at the branch head they want, though.


You cannot make another branch the default branch, by which I mean you cannot tell Mercurial that you would like branch-X to be checked out in a new clone. You should always make default the branch the branch that users want to checkout. This is described in the wiki.

People sometimes try to delete the default branch. This can be done by not creating one in the first place:

$ hg init repo
$ cd repo
$ hg branch dev
$ hg commit -m "Ha, no default branch!"

When there is no default branch present, hg clone will checkout the tip-most changeset. This is a bad idea since this changeset changes every time something is pushed to the repository. So if you have a dev and prod branch in the repo, then a new clone will checkout a "random" changeset depending on where the last commit was made. That is even more confusing that teaching people that default means "the normal branch where you should work by default".

share|improve this answer
    
Badly I have don't your "bad idea" (I was young). It's a way to repair it? I have made a question stackoverflow.com/questions/24558784/… with my problem. –  PhoneixS Jul 3 at 16:34

Is there any reason you couldn't just do your development in Default, and when it's released to production, you then branch it to Production?

UPDATE: given your request, have you tried using Named Branches explicitly in your commands?

share|improve this answer
    
We prefer to have our development done on a specific name (i.e., "dev") because it's explicit. –  Chris B. Oct 12 '10 at 14:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.