简体   繁体   中英

Bad idea to force creation of Mercurial remote heads (ie. branches)?

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:

替代文字
(source: grabby.info )

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?

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

https://www.mercurial-scm.org/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 :).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM