Uncommitted changes and merge

Giorgos Keramidas keramida at ceid.upatras.gr
Thu Sep 6 06:47:51 CDT 2007


On 2007-09-06 11:52, Lars Lundgren <lars at jasper-da.com> wrote:
> Hi.
> I have recently moved from cvs to hg.
>
> I'm trying to follow the Commit Early Commit Often principle. However
> I often get bitten by merge problems due to uncommitted local changes.
>
> I usually have two kinds of local uncommitted changes:
>
> 1. Local debug stuff that I have no intention of committing.
>
> 2. Some local changed are not ready yet, but I want to commit those
>    that are ready.

I think you basically need MQ.

With the MQ extension you can push several local changes on top of the
'ready' code, test them, pop them out again, refine them, 'rebase' them
on top of a newly pulled set of changesets, and so on.

Without MQ, you would have to *commit* the local changes and then merge
with the parent.  Future changes to the local patches would have to
appear in the history as standalone changesets, and some people (me
included) hate having to skim through tons of history to see the changes
of a single bugfix or feature.

With MQ, you can keep as many local patches as you want, keep refining
and refactoring the local patches, up to the point where they are ready
for 'commit'.  Then you commit them locally and merge as usual :-)

> Before I commit I take it as habit to pull and update from the main
> repo.

That's a CVS-related habit.  With CVS there is no way to "save" all the
local changes, so you have to "cvs up" and merge inside the active
workspace.  With Mercurial, it's a better idea to *commit* the local
changes (either as normal changesets, or as MQ patches) and _then_
merge.  This way you avoid all the risks associated with "bad merges" in
CVS, because at any point in time you can throw all the workspace files
away and restart the merge from a clean state :-)

> I try to limit my merge problems by whenever I want to commit do the
> full sequence: pull, update, merge, commit, push. However I then get
> the feeling that I was better of using cvs :(
[...]
> Is mq the solution to my problems?

Yes.

Give it a try, it absolutely rules :-)



More information about the Mercurial mailing list