ref: http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/
It’s been a while since we’ve been thinking about moving to Mercurial from Subversion at our company. We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team is already up to speed with it.
Although it’s quite simple to install it in a central server, the different articles on the web had me confused with too many options or with a different distro than Ubuntu. So, here is a dead simple list of things to do for installing Mercurial centrally for your dev team.
1. Log onto your server using SSH
2. Install mercurial from repository:
3. We need to have a directory to store our Mercurial configuration and repository files, so let’s create one and change it’s owner to the apache user so that apache can access them:
4. We’ll be creating a configuration that will allow us to host multiple repositories in this server. And we’ll be using CGI to serve the files through Apache:
5. We need to show the location of the config file to the CGI script, so open the file hgweb.cgi with nano or vim to update the line with “config = …” with the following and save it.
6. Now let’s create the file /var/hg/hgweb.config and write the location of the repositories:
Enter the following content and save the file:
7. As a final step, we’ll need to update the Apache configuration so that it executes the CGI when requested with a /hg prefix:
At the end of the defaul virtual host configuration and just before the </VirtualHost> tag, add the following and save it:
8. In order to take effect of the above change, we’ll need to restart apache:
9. Now you should be able to visit the server’s /hg location like http://rbs-server.com/hg from browser. However, you’ll be greeted with a username/password prompt as we’ve enabled that in our apache configuration above. So, lets add some user for our use.
It will ask for the password of the user admin twice and after you enter that, it will be stored in the file hgusers. You can add more users in the similar fashion, just ignore the c parameter as it was used to create the file first time:
10. Now visit the /hg path in your browser and you’ll see the empty list of repositories after you authenticate.
11. By default Mercurial only allows pushing changes through SSL, but in our case it was not necessary. Also, we wanted to give all our developers the push access to the repositories. For that, let’s update the system-wide mercurial configuration file /etc/mercurial/hgrc by adding the following lines at the end of the file and saving it:
12. Now that all is set, let’s setup a test repository so that we can clone it in our development machine:
This repository can now be accessed through http://rbs-server.com/hg/test and can be cloned in a development machine with the following command (mercurial must be installed already):
Hope this will make someone’s life easy. Enjoy the beauty of Mercurial!