Tagged as Linux
Written on 2008-04-22 17:47:37I've been meaning to set up a Version Control System for a long time now. VCS as a concept has been around for a while but recently a new paradigm in VCS called DVCS (for distributed version control system) has emerged. This new paradigm has cured or at least mitigated the warts of the old "centralized" version control systems and brought new benefits. The thing is there hadn't been a dominant VCS up until now and though some would argue to the contrary I would claim there still isn't. This article strives not to be concerned with the choice of a DVCS. The truth if you choose any of the 4 relatively high-profile DVCS systems that exist today (darcs, bazaar, mercurial, or git) you'll be able to migrate between any of them later without too much difficulty if you change your mind. I was initially leaning towards bazaar or git but eventually settled on (and am thus far quite happy with) mercurial. If you must know some of my reasoning I find that Dave Dribin has captured something close to my opinions.
sudo apt-get install mercurialand you're done. You'll have to set one thing in your configuration file before you can make your repository. Insert the following in ~/.hgrc with nano:
your_username = FirstName LastName
hg log. If there are no changes listed or exiting nano generated an error you should check your file permissions and see if entering the [ui] information in another config file (perhaps /etc/mercurial/hgrc) fixes the problem.
sudo apt-get install apache2. There should be a copy of the cgi script mercurial uses in /usr/share/doc/mercurial/examples/. Copy that to /var/www/cgi-hg/ and rename it index.cgi, then open it up with nano. Around the the third to last line (under def make_web_app) you should see something like:
return hgweb("/path/to/your/repo", "Your Repo Description Here")
sudo chmod a+x index.cgion the file so that Apache can execute it. You'll need to edit your apache config file so fire up nano again and open /etc/apache2/apache2.conf to insert the following:
Alias /code /var/www/cgi-hg
AddHandler cgi-script .cgi
Allow from all
sudo /etc/init.d/apache2 restartand try navigating your web browser to yourdomain.com/code.
allow_push = your_username
push_ssl = false
sudo htpasswd -c /etc/apache2/hg.pass your_usernamebut make sure to omit the -c argument when adding new users in the future or the file will be overwritten. Then you'll need to set up apache to check this information. Open /etc/apache2/conf.d/hg.conf in nano and add the following:
AuthName "Your Repository Name"
sudo chown -R www-data:www-data /path/to/your/repoand then restart the apache server again. That's it! Time to test it...
hg clone http://yourdomain.com/codeand you should see mercurial make a clone off of your server. Open one of the cloned files and make a small edit or add some new files, whatever you like. When you're done run
hg commitremembering to add commit messages. If you need to delete a file do it through
hg remove filename. Finally, try pushing your changes back to the server by running
hg push http://yourdomain.com/code. You should get asked for a username and password and if you give valid login information your changes should push through. Now navigate to http://yourdomain.com/code in the browser and see if the changes show up. If they do, you're off to the races.