Tagged as Linux
Written on 2008-04-22 17:47:37
I'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 mercurial
and 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:
[ui]
your_username = FirstName LastName
touch dirname/.hidden
.
hg init
hg add
hg commit
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.cgi
on 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
DirectoryIndex index.cgi
AddHandler cgi-script .cgi
Options ExecCGI
Order allow,deny
Allow from all
sudo /etc/init.d/apache2 restart
and try navigating your web browser to yourdomain.com/code.
[web]
allow_push = your_username
push_ssl = false
sudo htpasswd -c /etc/apache2/hg.pass your_username
but 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:
AuthUserFile /etc/apache2/hg.pass
AuthGroupFile /dev/null
AuthName "Your Repository Name"
AuthType Basic
Require valid-user
sudo chown -R www-data:www-data /path/to/your/repo
and then restart the apache server again. That's it! Time to test it...hg clone http://yourdomain.com/code
and 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 add
and hg commit
remembering 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.