A few years back, needing decent authentication and key management for Mercurial repositories, we wrote mercurial-server. Recently, we were in the position of wanting to use this with one of our clients, but this time it would need to run under Windows. This was a bit of a problem as it was designed for a Unix-type environment. On the other hand, it’s mostly written in Python, and we could use Cygwin, so how bad could it be?
As it turns out, not too awful. I needed to make a few small modifications, and we’ve now managed to deploy a working mercurial-server under Windows.
Having said that, here’s a BIG FAT WARNING: Windows is *not* a supported system. We’ve gotten this guide to work ok on Windows 7 and 2003, but the permissions are still broken in various ways to do with the underlying issues in Windows’ permissions system. Unix-based systems, especially Debian and derivatives are still the main target. This is very much a “you break it, you keep both pieces” guide, but patches are welcomed!
Assuming you’ve made it through that proviso, here’s how to do it:
hg clone http://hg.opensource.lshift.net/mercurial-server
and checkout the windows branch
Note that even if you’ve already got them installed in Windows, Python and Mercurial still need to be installed in Cygwin.
cygrunsrv -S sshd
to get sshd running. We need this because there’s no proper su in Cygwin (see the Cygwin FAQ for why this is)
sh windows.sh setup-windows
. If you had an external Python installed, this may fail. In which case try
then try again
and set the password for the hg user (created by setup-windows), then
mkpasswd -l > /etc/passwd
to add them to the Cygwin password database
sh windows.sh inituser-windows
to finish setting up the hg user
mkdir -p /etc/mercurial-server/keys/root/jay
cp my-key /etc/mercurial-server/keys/root/jay/spoon
chown hg /etc/mercurial-server/keys/root/jay/spoon
ssh hg@localhost /usr/local/share/mercurial-server/refresh-auth
The rest of the instructions in the normal mercurial-server documentation should now work. Note that although it’s possible to add keys/access info to /etc/mercurial-server it’s much easier to do things via the hgadmin repository (and can be done from places other than the Cygwin-running server), and doing things via /etc should probably be limited to only if you mess up the setup in hgadmin.
Hope that all worked for you! We’d love to hear if anyone else ends up using this out in the field, and anything extra you’ve done to get it working on your particular system.