- A script to query SVN logs by SQL 394 days ago
-
Quite often I find myself lost trying to do things that should be simply but they are not: try to answer this question “Being in a SVN working directory, how do you find all the log messages for the revisions that has been committed by someusername in the last month?”
Not so simple.
For this and other reasons, I’d like to have the power of SQL under my fingers, while inspecting SVN logs. So, in an hour, I hacked up this script that will permit you to query the (local) SVN logs with a (very) sql like interface.
It uses Ruby and Sqlite3, via gem. Basically it loads the log (in memory) as XML, then parses it and store revision informations in a (in memory) sqlite database. It then offers you a prompt from which you’ll be able to run queries.
Some example queries are:
- revision (lists all the revisions)
- revision where author=’claudioc’ (lists all the revisions by claudioc)
- count(*) where author=’claudioc’ (how many commits by claudioc?)
- message where date between ‘2007-01-01’ and ‘2007-02-01’ order by revision desc’ (list the log messages in a 2 months window, and order the list by revision number)
You can download the script here
Some extra notes:
The script is released under a creative commons license and you’re then welcome to change or patch the program as you like (you may want to report back patches).
The program works in memory, so the bigger the log file, the bigger the memory usage. It could be much better if the temporary table would be filled WHILE reading the XML (and not after).
The program use the current directory of the working copy a the starting point to inspect log. If you want to query the WHOLE application log, then move yourself in the root directory of your wc.
Due to the lack of real data types in Sqllite, date range checks could fail… a better approach (using the Ruby extensibily of the Sqlite gem) should be applied.
As usual, HTH
Comments
commenting closed for this article
→ 61648624
→

