Mercurial
Mercurial is a version control system, like subversion in that it manages changes in your code, but different in that it's designed to be distributed. Git and bazaar are also distributed version control systems. Mercurial is also written in python, which is cool. It's built in web interface is also excellent.
Setting Up On RedBrick
All the setup needs to be done on murphy, since that's the webserver. After that, you can access your code from anywhere.
First, we need to setup the repo that will contain the code
receive@murphy (~) % hg init hgrepo
Next, we setup the web access...
Step 1 - Create the directory, and copy in the python cgi
receive@murphy (~) % cd ~/public_html receive@murphy (~/public_html) % mkdir hg receive@murphy (~/public_html) % chmod 711 hg receive@murphy (~/public_html) % cd hg receive@murphy (~/public_html/hg) % cp /usr/share/doc/mercurial-common/examples/hgweb.cgi ./index.cgi receive@murphy (~/public_html/hg) % chmod 755 index.cgi
Step 2 - Set the repo location
Open the index.cgi in nano (or any other text editor) and on the second to last line replace /YOUR/HOME/DIR/YOUR/REPO with the location of the repo you created. For me, this is /home/member/r/receive/hgrepo - the location will depend on where your home directory is. Optionally, replace "repository name" with something cooler.
Step 3 - Set Up htaccess
receive@murphy (~/public_html/hg) % touch .htaccess receive@murphy (~/public_html/hg) % chmod 644 .htaccess
Open the htaccess file in a text editor.
################################## # Force all access to over https # ################################## RewriteCond %{SERVER_PORT} 80 RewriteRule (.*) https://www.redbrick.dcu.ie/~receive/hg ################################### # Options for rewriting hg access # ################################### RewriteCond %{SERVER_PORT} 443 #write base depending on where the base url lives RewriteBase /~receive/hg # Send requests for files that exist to those files. RewriteCond %{REQUEST_FILENAME} !-f # Send requests for directories that exist to those directories. RewriteCond %{REQUEST_FILENAME} !-d # Send requests to hgwebdir.cgi, appending the rest of url. RewriteRule (.*) hgweb.redbrick.cgi/$1 [QSA,L] ################################ # Options for password control # ################################ AuthType Basic AuthName "My Mercurial Repo" AuthUserFile /home/member/r/receive/.hgpasswd Require valid-user
You can use this htaccess file as a sample, but you'll need to make a few changes. The rewrite base should be set to the location on the webserver you created the hg directory. If you've been following the same example names I used it will be ~username/hg
Also, you'll need to set the location you're going to use for your htpasswd file.
Step 4: Create the password file
receive@murphy (~/public_html/hg) % htpasswd -c /home/member/r/receive/.hgpasswd receive
This will prompt you to enter your new password twice.
receive@murphy (~/public_html/hg) % chmod 644 /home/member/r/receive/.hgpasswd
Cloning the Repo
Once all this is done you should be able to login at https://www.redbrick.dcu.ie/~username/hg - of course you won't see any code there yet.
Go to whatever computer you want to start writing code on and clone a copy of the repo
andrew@laptop:~ $ hg clone https://www.redbrick.dcu.ie/~receive/hg
Now I have a copy of the repo on my laptop I can work on. You should read the guide to see all the commands that are available, but the basics you'll need are hg add and hg commit.
Pushing
After making changes you can push them back to your repo on RedBrick.
andrew@laptop:~/hg $ hg push
You can now look at the changes on the web interface :)