views:

62

answers:

2

I am developing a centralized web application, and I have a centralized Mercurial repository.

Locally I created a branch in my repository

hg branch my_branch

I then made some changes and committed. Then when I try to push, I get

abort: push creates new remote branch 'my_branch'!
(did you forget to merge? use push -f to force)

I've just been using push -f. Is this bad? I WANT multiple branches in my central, remote repository, as I want to 1) back up my work and 2) allow other developers to develop with me on that branch.

Is it bad or something to have branches in my remote repository or something? Should I not be doing push -f (and if not, what should I do?)? Why does Joel say this in his tutorial:

alt text

Occasionally I've made a change in a branch, pushed, switched to another branch, and changes I had made in that branch I switch to were mysteriously reverted to a previous version from several commits ago. Maybe this is a symptom of forcing a push?

+2  A: 

My suspicion is that others with more time can answer better, but here is something related I found:

http://mercurial.selenic.com/wiki/TipsAndTricks#Prevent_a_push_that_would_create_multiple_heads

It is related to a different option (specifically breaking push -f), but it mentions something along the lines of what you ask:

While a plain 'hg push' will warn you if you're going to create new heads, that is merely a warning on the client side intended to help/remind users that they may have forgotten to merge first.

Assuming this is an accurate statement then you are perfectly safe to do so.

Note however that I have only basic knowledge in Mercurial so shouldn't be used as a source of complete truth :).

Guvante
Since it says in the documentation what you quoted, it seems pretty definitive to me that it's okay to use push -f and have remote branches.
Chad Johnson
+2  A: 

No, it's not bad to force the push when you create a new branch. The error/warning is issued because the new branch causes the repository to have two topological heads. That is, there are now two changesets without children: the tip of your default branch, and the tip of your new branch.

With Mercurial 1.6 (to be released in two weeks time) you will be able to do

hg push --new-branch

to allow the creation of new remote branches. This is safer since --force disables all safety guards, whereas --new-branch only allows you to create a new branch.

Martin Geisler
Good to know. Thanks for posting.
Chad Johnson