Mathematics, philosophy, programming, in-line skating and everything in between. More about me…

My Blog

My Latest Tweets

Follow me on Twitter…
English | Czech
Choose your language. I write in English, but I translate most of my articles to Czech as well. Zvolte si jazyk. Píšu anglicky, ale většinu svých článků překládám i do češtiny.

Easier Subversion Operation – Subversion Shell

Subversion version control system is one of the tools I use every day. Over the time I realized that many Subversion tasks are more or less repetitive – checking the logs of the last few revisions, adding or removing files, comparing changes, committing to the repository, updating the working copy… in the end I created Lazy Programmer’s Best Friend™. Meet SVNshell, a script simplifying everyday Subversion tasks.

SVNshell is basically a bunch of aliases and functions. The script itself is named svnshell.rc and I use it as a Bash configuration file:

alias SVNshell="bash --rcfile $HOME/bin/svnshell.rc"

The script also includes (sources) the original ~/.bashrc so all your personal Bash preferences take effect in SVNshell, too. The script itself first defines several handy aliases, for example alias log='svn log --revision HEAD:PREV' or alias cp='svn cp'.

The shell prompt (PS1) is greatly enhanced. The script modifies it so that it contains only relative path within the working copy. Whenever I work deep within a project’s directory, I don’t really need to see that the project lives in /home/zephyr/Projects/. The prompt also shows the name of the project and a notice that SVNshell is active. Example:

(SVN) nexus:/data/results$
(SVN) nexus:/data/results$ pwd
/home/zephyr/Projects/nexus/data/results
(SVN) nexus:/data/results$ cd ..
(SVN) nexus:/data$ pwd
/home/zephyr/Projects/nexus/data

Another improvement is the commit function. I found myself doing the same commit ritual over and over again:

  1. check the changes in the project with svn status
  2. do the commit with svn commit or svn commit -m 'message'
  3. update the working copy using svn update

The commit function automates this process. All I have to do now is writing the commit log. Example:

(SVN) fooProject:$ commit
A      main.c
A      doc
> This is a commit log.
Adding         doc
Adding         main.c
Transmitting file data .
Committed revision 1.
At revision 1.
(SVN) fooProject:$ log
------------------------------------------------------------------------
r1 | zephyr | 2008-07-22 13:47:57 +0200 (Tue, 22 Jul 2008) | 1 line

This is a commit log.
------------------------------------------------------------------------

The last feature of SVNshell is the “start-up procedure” – when executed, the script prints out the commit logs of the last two revisions and the current svn status of the working directory. It helps me to remember what were the last changes and what work is going on at the moment.

One last note: the script works properly when started in the root of the working copy. If you have your working copy in /home/user/project, you need to run SVNshell in /home/user/project, not in /home/user/project/include, for instance.

Feel free to give SVNshell a try. I’ll be happy to hear your opinions and suggestions.

Download: svnshell.rc (1063B)

July 22, MMVIII — Linux, Programming and bash.

Speak your mind

Allowed HTML tags are a, blockquote, em, code, li, ol, p, pre, strong, ul. Links to other comments in the form “[IV]” or “[4]” are detected automatically.