« Find Memory Leaks! | Main | Champagne! »

20081031 Friday October 31, 2008

Mercurial Tip: Checking in regularly with uncommitted changes in your clone

NetBeans, like OpenJDK and OpenSolaris, uses the Mercurial distributed version control system. I'm a big fan of of distributed version control. However, one thing that drives me nuts is this error message:

% hg merge
abort: outstanding uncommitted changes
This isn't just going to be a rant - I've finally found a solution which is working extremely well for me. I've suggested it to some other developers who have also reported that it works well for them, so I thought I would share it with you.

The reason I run into this all the time is my preferred style of work:

It turns out that the above requirements are tricky to fulfill with a default setup. Here's what happens.
Comments:

Yes, this works, although I use hg fetch instead of hg pull/hg merge.

But I use Mercurial Queues rather than a "push clone". When I get the "outstanding uncommitted changes" error, I do the following:

hg qinit -f mypatchname.diff
hq qpop
hg fetch
hg push
hg qpush

Very nice.

Note that when you want to commit your local changes that were put on the patch queue, you have to do the following, a minor annoyance...

hg qpop
hg import .hg/patches/mypatch.diff

Posted by David Van Couvering on October 31, 2008 at 01:20 PM PDT #

Hi David,
thanks. I'm aware of Mercurial Queues, but the main reason I really recommend having an alternate clone to people new to Mercurial is the ability to throw it all away when something goes wrong during a merge. I also like the ability to be able to build/test individual changesets in isolation before pushing them.

Posted by Torbjorn Norbye on October 31, 2008 at 02:05 PM PDT #

Your description and level of detail for how to use Mercurial is exactly what I've been looking for. I'm new to Mercurial and am suggesting it for company wide use where I work. Thanks Tor.

Posted by Greg Strockbine on November 03, 2008 at 08:22 AM PST #

I agree with David and I prefer using MQ for working on several things at once in one repo (code for each bug/enhancement is stored in a separate patch). It's much faster, but also requires some discipline and awareness of which patch is currently on the top of the stack.

Once a patch is ready to be permanently moved to the main repo, hg import + hg push will do the job.

There are times when working on a separate clone makes more sense, mainly when working on major changes for a longer period of time.

Posted by Igor Minar on November 10, 2008 at 02:08 PM PST #

Hi Tor,

------------------
hg merge
abort: outstanding uncommitted changes
------------------

I had similar issues (when I had to tweak GSF modules in the clone of /main-golden to add friend dependencies on my module). I fixed it like this- I edit the .hg/hgrc file and changed the "default-push" value back to the one pointing to /main-golden.

Will this work all the time?

Then, as I had configured Hudson yesterday to automate builds for /main-golden locally. I ran the build myself and it worked. Also, build succeeded after nearly 100 minutes!

Posted by Varun on November 11, 2008 at 03:26 AM PST #

Post a Comment:

Comments are closed for this entry.