Keeping Mercurial history linear
When ever I work on a project that uses Mercurial for DVCS there always seems to be a lot of "Merging up stream." At first I thought "Great, looks like this project's having new features merged often". On further inspection most of this merging was not necessary. I believe this is due to the fact Mercurial does not have a rebase command enabled by default. Thankfully though there is one shipped with Mercurial that is very easy to enable.
Add the below to your ~/.hgrc
config file
[extensions]
hgext.rebase =
You have rebase, now what! When you have finished your changes and committed them to your local repository, rather then pulling changes from the remote and merging them. You should pull from the remote and rebase your changes with the rebase command.
hg rebase --source 3 --dest 4
Where 3 is your last local commit and 4 is the last remote commit. Rebase will replay each local commit on top if the destination. If there are any conflicts Mercurial will stop - allowing you to fix the conflicts. Once you have fixed the conflict you can continue the rebase with hg rebase --continue
or abort it with hg rebase --abort
Finally when the rebase is finished you can push your changes to the remote.
So why would you go through all this. One of the main benefits is you are able to fix the conflicts locally, keeps the history clean, making it easer for others to understand what is going on. For information on the rebase command take a look at the rebase project page