I have just found a pretty cool way to set up a centralized mercurial server called “mercurial-server”, but unfortunately I haven’t got it all quite working yet. Installation was dead simple:
$ cd src/tarballs $ wget http://hg.opensource.lshift.net/mercurial-server/archive/release_0.6.tar.gz $ cd .. $ tar -zxvf tarballs release_0.6.tar.gz $ cd mercurial-server-release_0.6 $ sudo ./install
With that done you need to upload your ssh public key (i.e. ~/.ssh/id_rsa.pub on your local machine, not the server on which you are installing mercurial-server) and place it in /etc/mercurial-server/keys/root/[username]/[hostname_of_local_machine], although I am assuming that the extra directory ([username]) and naming your pubkey after your local hostname is for ease of administration only.
I had set up some rather restrictive rules about what groups could enter the server by ssh, in my /etc/ssh/sshd_config file, which effectively thwarted my first attempts at doing anything (say cloning the hgadmin repo) by ignoring my pubkeys and asking for the password to the hg user. I was rather stumped at that for a while until I remembered my sshd_config being… paranoid.
With that out of the way I could attempt a hg clone ssh://hg@jupiter/hgadmin, which failed miserably with a stack trace indicating that I didn’t have the python-dispatch package installed. I tried Googling for a list of dependencies, but the name “mercurial-server” doesn’t seem to be well established with Google yet, so most results end up with questions about “mercurial” and “server” (placing mercurial-server inside quotes, it does nothing!). Anyhow, one sudo apt-get install python-dispatch later and I got a new stack trace:
$ hg clone ssh://hg@jupiter/hgadmin remote: Traceback (most recent call last): remote: File "/usr/local/share/mercurial-server/hg-ssh", line 89, in <module> remote: try_cmd(os.environ.get('SSH_ORIGINAL_COMMAND', '?')) remote: File "/usr/local/share/mercurial-server/hg-ssh", line 56, in try_cmd remote: dispatch.dispatch(['-R', repo, 'serve', '--stdio']) remote: File "/var/lib/python-support/python2.5/mercurial/demandimport.py", line 75, in __getattribute__ remote: return getattr(self._module, attr) remote: AttributeError: 'module' object has no attribute 'dispatch' abort: no suitable response from remote hg!
This was, as I realized when installing the mercurial-server temporarily on another much more up to date system, due to an outdated version of mercurial installed on the system. I really ought to do a dist upgrade or a complete reinstall of the entire box now while I don’t have much of value on it, but I opted for the less time consuming way of just uninstalling the old (repository version) mercurial and installing from source. And now all is well
All there is to it now is experiment by managing the server from its hgadmin repository and see if it is as awesome as it seems.
The one really nifty thing about this is that this way I could expose my repository to people I know and trust simply by adding their ssh pubkey, without having to worry about giving them a shell on the server. Very cool.