Sam’s Network Simulation Cradle Blog

15 Mar 2008

Fun with subversion repository history: a visualisation

Filed under: General — sammydre @ 8:34 pm

Some time ago I hacked up a little script to view my subversion repository version over time. I lost the initial script but I’ve recreated it today. Thought it was interesting to look at as the history dates back to 2003. Creating this is very easy with the help of svn log.

  1. svn log svn+ssh://host/repository/ | grep -E "^r[0-9]+" | awk ‘{ print $5, $1 }’ | sed ’s/r//’ > repo.txt

Produces a file like:

2008-03-12 1681
2008-03-12 1680
2008-03-11 1679
... etc ...

Looks good for graphing with a program like gnuplot:

set xdata time
# The format of time found in the file
set timefmt "%Y-%m-%d"

set term png
set output "repository.png"

set xlabel "Date"
set ylabel "Repository revision"
set title "Repository version over time"

# The time format actually shown on the x-axis
set format x "%Y"

# It's tricky to get the tics right in time mode, as you have to specify increments in seconds.
# I find it easier to just specify what dates I want shown
set xtics ("2003-1-1", "2004-1-1", "2005-1-1", "2006-1-1", "2007-1-1", "2008-1-1")
set nokey

plot "repository.txt" using 1:2 with lines

And this produces the following result:

Sam’s research repository version over time

The hickup in the graph for me is due to an import with cvs2svn. Looks like the dates don’t quite increase as one would expect (this can be seen in the svn log output, too). In general the approach appears to work well enough, though.


  1. Great idea! It works very well.
    The bash script can be simplified to just use GNU awk.

    svn log svn+ssh://host/repo/ | awk ‘/^r[0-9]+/ { print $5, substr($1,2)}’ > repo.txt

    Comment by Staz — 16 Mar 2008 @ 10:07 pm

  2. Yeah, it’s probably a better idea to use Awk like that — I’m forever abusing Awk by piping its output to sed and the like rather than using the features of awk itself. Maybe oneday I’ll read the manpage.

    Comment by sammydre — 17 Mar 2008 @ 3:39 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress