hg clone fails with 255 error

I recently encountered an issue with cloning a Mercurial repository where it would fail with an obtuse error stating that “[command returned code 255 Mon Mar 25 11:39:55 2013]”. My initial Googling implied that this was caused by a server timeout but the problem persisted even after increasing the timeout on our Apache web server.

The clone was always failing on one particular file - a 600Mb binary. (Don’t ask…)

[Read More]

How to show which .hgrc Mercurial is using

Mercurial loads a bunch of different configuration files and overlays their values on top of each other. The hgrc man page shows the order in which these files are loaded.

I encountered an issue recently where I knew that hg was using an erroneous setting but I had no idea where the setting was coming from.

The magic answer is

hg --debug showconfig  

This will output all the current settings, along with the name of the file that it got each setting from. Very useful indeed.

[Read More]

How to take local in Mercurial without a merge conflict

When there’s a merge conflict in Mercurial, TortoiseHG will give you the option to ’take local’ or ’take other’ in addition to resolving the conflict.

However, sometimes you may want to ’take local’ or ’take other’ when there’s no merge conflict.

To take local:

hg merge --tool internal:local <rev>  

To take other:

hg merge --tool internal:other <rev>  

Slow Mercurial clone

I recently set up a Mercurial server (Windows, Apache, ActiveDirectory and hgweb.wsgi). However, cloning our 1Gb repository took an hour or more and often failed.

The only information in the Apache log was

mod_wsgi (pid=1234: Exception occurred processing WSGI script
'C:/hg/hgweb/hgweb.wsgi'  
IOError: failed to write data  

The solution was to disable compression by adding the following lines to hgweb.config

[server]  
preferuncompressed = true  

By default, Mercurial will compress everything before sending it down the pipe. This makes sense if you have a powerful server and a slow network, but the opposite was true for us - Mercurial’s hosted on an old dual-core Windows VM connected to a 1Gb corporate LAN.

[Read More]

Mercurial ignore file for Maven projects

I find it hard to remember all the .hgignore settings for a new Mercurial repository that I need, so here’s a bootstrap version

syntax: glob
.hgignore
*/target/**
*/.settings/**
*/.classpath
*/.project
*.log
*.orig

Tools of the trade

Many large companies have explicit policies around which development tools to use. For example, “Here at Really Big Corporation we use CVS, Ant and Eclipse”. I understand that companies need to limit the proliferation of tools to ensure familiarity and supportability, but sometimes a little flexibility would be nice.

When I hire a tradesman to do work on my house I don’t tell him that we use handsaws here, not tablesaws. I trust him to use the tools that make him the most productive.

[Read More]

Mercurial changes how you work

I’ve recently started using Mercurial, which is a distributed version control system.

DVCSs initially struck me as a solution looking for a problem. SubVersion seemed good enough for our purposes at work, but we decided to try out Mercurial for one iteration to see what all the fuss was about.

Perhaps the most significant difference between SubVersion and Mercurial is that Mercurial uses a local repository. This subtle distinction significantly changes how you work because you can commit your changes without having to publish them. A ‘commit’ in Mercurial is like a savepoint in database-speak - it gives you a safe place to roll back to if things go awry. Once you’re happy with your changes you can use the patch queue to fold all your commits into a single changeset and ‘push’ (i.e. publish) your changes to the central repository.

[Read More]