Hackable Mercurial for Windows

An approach to easily hack on the Mercurial source on Windows.

1. What is the Hackable package?

Compiling Mercurial is a significant barrier to testing and developing Mercurial on Windows. This package attempts to minimize that barrier by including:

2. Downloading and using

The package can be found here. Simply download, unzip, and run the included hg.exe. This package will not interfere with your existing Mercurial or Python installation.

<!> There is usually no need to download new copies between releases, simply pull and update.

/!\ This package includes no global configuration, so if you're not already using Mercurial, you will need to configure your username and merge tools.

3. How it's built and how to build your own from scratch

Needed components:

Steps:

4. Running the test suite under MSYS

Most of the test suite can be run on windows too (but only in the unreleased 2.1 which currently can be found in the ‘default’ branch). Writing tests and debugging failures might require both knowledge of the traditional unix environment and of the windows environment.

The tests that can’t be run on windows will automatically be skipped, so no test failures should be seen. It is not acceptable that so many tests are skipped - please improve that.

Creating a hg-winhack package and running the test suite requires almost the same environment. The following instructions will thus contain a lot of duplication of the instructions given above, and the instructions could perhaps be merged. (The 2.0.x “hackable” can’t be used in the default / pre-2.1 branch where testing on windows passes cleanly, so new binary modules will have to be built anyway.)

4.1. Install MinGW/MSYS environment

4.2. Build hg-winhack

# create build directory
hg clone http://selenic.com/hg hg-winhack   # bootstrap Mercurial somehow
cd hg-winhack
# install python
wget http://python.org/ftp/python/2.7.2/python-2.7.2.msi
msiexec //i python-2.7.2.msi //qb   # avoid MSYS magic mangling of '/i'
cp -ar c:/Python27 hg-python27   # python can now be uninstalled again
sed -i 's, -mno-cygwin , ,g' hg-python27/Lib/distutils/cygwinccompiler.py
# build Mercurial extensions
hg-python27/python setup.py build_ext -i --compiler=mingw32
# create hg.exe launcher
sed 's,^#!/usr/bin/env python,#!hg-python27/python27.dll,g' hg > hg.py
wget http://effbot.org/media/downloads/exemaker-1.2-20041012.zip -O exemaker.zip
unzip -j exemaker.zip '*/exemaker.exe'
rm exemaker.zip
mv exemaker.exe hg.exe
# zip it and ship it
cd ..
zip -r hg-winhack-x.x.zip hg-winhack/

Note that this will leave you with both a hg.exe which can be used from windows, a hg.py which might be picked up if you have python installed, and a hg which might be picked up if you run in MSYS ... and will fail if it can't find python and the Mercurial modules.

4.3. Run the test suite

cd hg-winhack/tests
export TMPDIR=c:/tmp   # to avoid path that contains ~ which in general would require escaping
PATH="`pwd`/../hg-python27:$PATH" ./run-tests.py -l

4.4. Run tests involving Git

If you have Git installed on your Windows box, hg-winhack will incorrectly detect that git command is available, and will try to run Git-related tests. It will fail to do so, because it cannot run "git.cmd" from shell.

#!/bin/sh $COMSPEC //C git.cmd $* 

5. See also


CategoryDeveloper