开发者

Why is a --new-branch flag needed?

Isn't this a normal workflow?

[default] $ hg branch foo

[foo] $ [... some commits ...]

[foo] $ hg update default

[default] $ hg merge foo

[default] $ hg commit -m "merged foo"

[default] $ hg push
abort: push creates new remote branches: foo!
(use 'hg push --new-branch' to create 开发者_开发知识库new remote branches)

What is the otherwise ideal way to do branching → merging → pushing?


The mercurial philosophy is that you should not be pushing things which make it harder for other users of the repository. Relevant to this question is that multiple heads make it harder for other developers, since they would then need to merge your changes. Hence by default pushing new heads is rejected by the server. The -f option was used to allow pushing new heads.

However, the case of pushing a new named branch is quite different conceptually to pushing a new head on the same branch. Many workflows (including mine) do each task on a separate named branch. The --new-branch option allows you to push up a new branch, whilst rejecting new heads on existing branches. It's also different (as you've seen) because it's needed even if the new branch does not create a new head (due to merging).

My personal feeling is that new branches should be allowed by default, but the mercurial developers prefer otherwise.


This is a one-time thing. Just use --new-branch the first time you push a (new) branch. It's normal.

Every other push can remain as hg push, no --new-branch flag.


That depends on what the branch is used for.

Is it used internally in your own repository clone it would be appropriate to commit your changes to your branch as long as you develop on your feature decoupled from the others.

After you finished you'll have to invest some work to keep track on the efforts of other people who may have done changes on the default branch

Then you should update in their changes, resolve the conflicts commit your part. Switch over to default and make your feature part of the default branch by merging in your changes. Now you can close your branch, commit the stuff and push it!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜