How to auto-merge 2 heads with mercurial

末鹿安然 提交于 2019-12-23 08:28:31

问题


We just changed over to mercurial from subversion and there is one thing that is taking up more time than expected; merging heads.

We love the fact that it keeps merges independent from the 2 commits (compared to subversion) but we end up on a regular basis merging 2 heads for unrelated changes.

Simple scenario. Both me and Bob are up to date. We both have ou repo up to date on default (aka main) branch and do improvement in different files.

We commit and only one will be able to push to the central server, the other one will create 2 heads. Then, pull, select 2 heads, merge (it will go easily since changes are on different files). Commit, then push.

Therefore, is there an extension that does these steps Attempt merge If no conflicts Commit else Cancel merge

We are looking to have this run on an automated server, so +1 it this is command line and another +1 if it can do the merge without touching the working copy.

Thanks!


Update:
We ended up doing a few python scripts to manage the most common tasks (merge up & build; merge 2 heads).

Thanks for the help!


回答1:


It sounds like you should be able to use hg fetch for this. It'll pull the changes from the server, merge, and then automatically commit the merge. It does prompt for merge conflicts as well. It's included with Mercurial, so just add

fetch =

to your hgrc, and you should be all set. It doesn't automatically push, but that's usually a bad idea anyway. You would typically want to run tests and resolve any merge problems before pushing your code out to everyone else.




回答2:


Are the merges really taking that much time? If they're "unrelated changes" doesn't it just take a blink?

Someone already suggested fetch and someone else will probably suggest rebase, but personally I consider merging to be coding, and want it to be manual. It takes almost no time and it's an opportunity to give a good message like "Pulling in Jane's work half-way through my FooBar work" (instead of the useless commit messages fetch provides).



来源:https://stackoverflow.com/questions/5215445/how-to-auto-merge-2-heads-with-mercurial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!