Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-merge 2 heads with mercurial

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!

like image 278
Babouchk Avatar asked Mar 07 '11 03:03

Babouchk


1 Answers

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.

like image 180
derekerdmann Avatar answered Oct 05 '22 10:10

derekerdmann