SVN Scripts and Tools

At Crowd Favorite we use Subversion for source control and document distribution and management. Last week, we were reminded just how much we rely on it.

We made the move from an outdated server to a more properly equipped one, and also used a more suitable domain and set up SSL and all the stuff we should have had months ago. We also set up Warehouse, which is a nice Rails web front-end for SVN. It also has a very poorly documented installation process and we spent about 12 man hours getting it set up. We still don’t have the permissions working right, but the web interface is very handy and there is more there than you realize at first glance.

In the server move we also lost our SVN commit e-mails for several days, and were having more trouble than we expected getting them set up again (the 4 different server documentation pages we found were wrong or outdated). In the end we just used the mail notifications from Warehouse instead.

SVN is not without its flaws, and I’ve been reading great things about Git and Mercurial recently, and the benefits these systems offer over SVN are compelling. However, SVN has one big benefit over these up and coming systems: existing tools and integrations.

I’ve come to use the SVN integration in Path Finder about half the time now. I also use the SVN integration in BBEdit. Other folks on the team use the integration in TextMate or a standalone tool like SVN X. Still others are waiting for enticing varporware to materialize. The point is, the tools around a system are also important.

I use a desktop computer at home and a laptop at the office and on the road, so SVN is invaluable to me as a synchronization tool as well. Since we have several different SVN repositories, I’ve created some simple scripts to make it easy for me to update all of the repositories and check them all for uncommitted changes. Disclaimer: there’s nothing fancy here, and I’m not a bash guru, so suggestions and improvements are welcome.

Updating

First create a simple script to update all of the repositories (svn-st-all.sh):

#!/bin/sh

svn up ~/src/repo-1
svn up ~/src/repo-2
svn up ~/src/repo-3

Make sure the .sh file has executable file permissions.

Then set up an alias in your .profile so you can call the script with an easy command:

alias svnstall=/path/to/svn-up-all.sh

Checking for Uncommitted Changes

First create a another simple script (svn-st-all.sh):

#!/bin/sh

svn st ~/src/repo-1 > ~/Desktop/svn-status.txt
svn st ~/src/repo-2 >> ~/Desktop/svn-status.txt
svn st ~/src/repo-3 >> ~/Desktop/svn-status.txt

open -a TextMate ~/Desktop/svn-status.txt

This one checks the status of each repository and puts the result in a file, then opens that file in TextMate. Again, make sure the .sh file has executable file permissions.

Now create an alias for this one too:

alias svnupall=/path/to/svn-up-all.sh

Now in your terminal you can type ‘svnupall’ to update all of your repositories, or ‘svnstall’ to check all of your repositories for uncommitted changes.

Hopefully this will help someone else avoid the old “crap, I must have forgotten to check that in from my other machine” situation. :)

This post is part of the thread: Version Control – an ongoing story on this site. View the thread timeline for more context on this post.