Posts Tagged ‘Subversion’

Snow Leopard and SCPlugin

February 4th, 2010

Snow Leopard BoxI recently upgraded my laptop to Snow Leopard and have, as of yet, not been wowed by it. Whilst in conversation with a friend I defended the OS and demanded that the latest release was not a Service Pack as he suggested and is an entirely new OS. I installed it and expected the world to tremble as I booted up, I wanted to see an instantly noticable improvement for the ‘average’ user such as myself.

No such luck

Since installing the update I have not noticed an increase in speed as was anticipated and to make things annoying I have had to completely reconfigure my local web server and find a new Subversion application to use. It took me about a week to recover fully from the upgrade. The laptop has been sadly crashing (albeit not catastrophically) once a month or so.

On the bright side though, and there is a really big bright side, my laptop now sports the latest version of the OS. OSX is still as pretty and user friendly as it ever was and, after a month or two of use, you really start to notice the differences and little tweaks that have been added. I had problems before the upgrade with deleting ‘locked’ (?) items from my trash (there was a keyboard shortcut I now know) but now there is a handy dialogue box that asks about it on emptying the can. There are a few other stylistic changes I notice although I am aware that the major change is the extension of integration of Cocoa which is nice (apparently).

How to recursively remove .svn directories

July 23rd, 2009

Regular readers may have clocked onto the fact that I use Subversion. Well the way it works it to keep a hidden set of directories within your checked out repository. It uses this to track any changes etc.. Each directory is called ‘.svn’ and is within each and every directory and subdirectory you have.

The problem

Now I know I am not alone in saying that when you want to upload the files to a remote server you have to do one of two things

  • Upload the files and .svn directories to your server which is likely to take twice the time and twice the disk space
  • Make a separate local copy of your files and then remove the .svn directories one by one.

I prefer to take option two although in recent months I have taken on the former through sheer laziness. I decided to look for a solution and found my answer…

The answer

For windows machines you need to create a secondary copy of your files to upload, this means it won’t wipe out your local repository files (the ones you want to keep). Next, create a ‘.bat’ file (batch file for executable scripts). The simplest way to do this is to open notepad and doing File > Save as > remove_svn.bat after copying in the code below. It needs to be saved in the root directory of your repository copy. This is important if not it will recurse all directories below the one it is placed in.

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
  rd /s /q "%%i"
)

I have done all the hard work for you on this one.
Just click the following link:
Remove SVN Files (Windows) (82 bytes)

For Macs and other Unix based machines you need to do something similar. This time we simply run a command on the shell (or create a shell script out of it). Again this must be placed in the directory you want to recurse through.

find . -name .svn -print0 | xargs -0 rm -rf

The Credit

Credit for these snippets goes to the following sites. Whether they were the original authors or not I don’t know but credit where credit is due etc..

Mac version – http://snipplr.com/view/201/remove-all-svn-directories/
Windows Version – http://bluespark.tumblr.com/post/23853870/remove-svn-subfolders-on-windows-xp-vista

Subversion server sertup and configuration for dummies

March 7th, 2009

For those of you that don’t know what it is, Subversion (or SVN for short) is a popular open source version control system used all over the world. Previously people have used other systems like CVS however SVN seems to now be the standard. Firstly here is a little information about clients, skip past it for the server section.

Clients

An SVN client is (obviously) a piece of software that allows you to interact with a central ‘repository’ (or repositories if you work on version controlled files from multiple sources). They facilitate communication and interaction with the SVN server, actions like ‘checking out’ repositories, ‘committing’ your changes and ‘merging’ in other people changes to your own local copy.

This might be a little basic for this tutorial so I shall move swiftly onto client software. The Subversion project is hosted by tigris.org who release the source code for Subversion itself. Volunteers port the code onto different platforms. I can only recommend the software I have used to they are as follows:

  • TortoiseSVN – A free and very popular windows client with Explorer integration
  • SCPlugin – A free, yet buggy, Mac client whose advantage is integration with Finder
  • Zigversion – A Mac client which is free for personal use. No Finder integration (to my knowledge)

Server

This section will detail how to install and configure a Subversion repository on a Unix based system. It assumes that the ‘yum’ package is installed however for those of you who don’t have it or are unaware of what it does then please read Valerie Aurora’s Linux Basics guide where there is a helpful section called ‘Finding and Installing Software’.

First things first, install subversion and its dependancies using yum. This is a nice one liner to get the job done for you.

yum -y install apr apr-utils http-devel mod_dav_svn subversion

Yes it was that easy! One command just installed Subversion and it’s dependancies (let me know if i have missed any). The next thing to do is configure a new repository and setup access using htaccess.

The first thing to do is to create a new repository. For this tutorial I will be using ‘/usr/local/svn’ as a place to store repositories however you can put it anywhere you like on the file system.

Firstly, create the directory ‘svn’ using the mkdir command (within /usr/local/ :) ) and then chown it recursively to apache:apache. Move into it and use the following command to set up your first repository (which in this case is called test but obviously it can be anything you choose):

svnadmin create test

The above install process also adds a new config file into the apache conf.d directory (/etc/httpd/conf.d/). The config file is called subversion.conf, within which is an example block to uncomment to set up http access to the respository and set up htaccess permissions.

The most basic example of what to put in this file is below. It will set up a virtual subdirectory of your website so try to either make the name unique or not use the name on any of your sites on the same server. This example will set up a subdirectory called ‘svn’ so if your site is http://127.0.0.1 then your Subversion path will be http://127.0.0.1/svn

<Location /svn>i
	DAV svn
	SVNParentPath /usr/local/svn
</Location>

After making any changes to this file (and any file served by apache for that matter) then you must restart apache for them to take effect. You can then view your repository in your browser and assuming you see a blank page with something that resembles ‘Revision 0:’ or the name of your repository as a link then you are ready to start using it.

For those that run multiple sites using VirtualHost directives then the above section of code can be included within one as per the example below which should create access to Subversion on a site named ‘svn.localhost’.

<VirtualHost *:80>
	DocumentRoot /usr/local/svn
	ServerName svn.localhost
	<Location /svn>
		DAV svn
		SVNParentPath /usr/local/svn
	</Location>
</VirtualHost>

Access Control

You may want to configure access to your repository allowing only certain people and groups to have different levels of access. Subversion allows a couple of ways to do this but the most common seems to be htaccess. Configuring this is more or less the same as configuring htaccess. See the example below:

AuthType Basic
AuthName "Subversion"
AuthUserFile "/etc/httpd/conf.d/svn_passwd"
Require valid-user

The above 4 lines can be slotted in beween the ‘<Location>…</Location>’ tags. It tells Apache not to allow access to anyone except those that have their crudentials within a file (in passwd format) at the location specified. The ‘AuthName’ line is optional, all it does it put a name onto the box that pops up asking for login information.

The file that I have called svn_passwd can be situated anywhere on the system however it would be sensible NOT to put it anywhere that can be served by any of your websites. Generate the ‘svn_passwd’ file using the following command if it doesn’t already exist.

htpasswd -cm /etc/httpd/conf.d/svn_passwd admin

You will then be prompted for a password for the user and once entered (twice?), after Apache has been restarted you won’t be able to get access to your repositories without those details. The name of the user you choose for this doesn’t have to be a system user and if it is (like admin for example) then the password you use doesn’t have to match its counterpart.

After restarting Apache again you will be only be able to access your repository with a correct set of credentials defined in the htpasswd file.

That concludes the tutorial for now. I hope that I have given you a good round knowledge of Subversion server setup which in turn will enable you to easily run your own version control system. There will likely be snags along the way, there always are. If in doubt then Google it! or ask me (who will likely Google it anyway :) )

Resources

http://svnbook.red-bean.com