Mercurial (Hg)

This is a page dedicated to Mercurial (Hg), a distributed source code versioning system

Download

Download the TortoiseHg with the latest Mercurial bundled in one easy installation package for Windows from http://tortoisehg.bitbucket.org/.

BitBucket

    • Setting up SSH with BitBucket (link).

Pay attention to the location and the name of the plink executable.

Setting up web access

To configure web access, I used the combination of the two tutorials (old and new). See the attached hgweb.zip for my example configuration that works on Windows 2008 R2 / IIS 7.5 with Python 2.6. This archive contains all the files that need to be in the web directory.

Copy the templates directory from your Mercurial installation to allow stylesheet support.

I followed the new instructions that describes which components to install. Download and install Python, Mercurial, and a few additions, listed there. Add mercurial/bin directory to path and check that it works. Configure the hgweb.cgi script and hgweb.config file. Add .cgi handler and point to Python, as described in the old instructions below. WSGI did not work for me so I reverted back to CGI.

The web.config in the zip file also contains the Rewrite instruction to hide hgweb.cgi from the URL.

New version of installation tutorial for IIS 7 is here.

Old: There is a good illustrated tutorial (link).

Running manually:

The easiest way to serve Mercurial repositories on Windows by following the instructions here and creating a service (see here) that simply executes the command below. However, this doesn't work.

hg serve --webdir-conf C:\inetpub\wwwroot\hg\hgweb.config

Create a service with hgservice (link). Or, manually

sc create Mercurial start= auto binPath= "D:\Program Files\Mercurial\HgService\HgService.exe"

and

sc delete Mercurial

Error 500 - Access Denied

If you get the above error when trying to push changes to the remote server, check the permissions on the server filesystem. IUSR group must have full access to the directories that are served as repositories.

SCC Provider

Mercurial can be set up as an SCC provider, which then can be used by different applications like Enterprise Architect and Visual Studio.

SCC Provider for Mercurial available here.

Versioning with MSBuild

Versioning project (link) enables integration of the MSBuild on the CI server with source code versions in the Mercurial repository by tagging the code with the build number.

Git Parallels

To push only the current working branch to the remote repository you can use 'nudge' - a concept of pushing just the current branch and not all branches, which is the Mercurial default behavior.

More info here.

Working Together with TFS

See my blog post about using Mercurial with TFS. The PowerShell scripts are in the repository: