1 Comments

A subversion repository contains a tome of information about your code and looking at this data can prove very useful in identifying trends in development. Quite some time ago I put together some batch files and a small application (for filtering SVN logs) to automate the generating of statistics using StatSVN and SvnStat. I am sharing this with you today.

Example of high level change overview chart. This is one of the many charts and graphs available in StatSVN.

StatSVN_Sample

Example of changes per user graph. This is one of the many charts and graphs available in SvnStat.

SvnStat_Sample

The reason I’ve looked at this again was because I wanted to change the helper application to a C# script file (.csx) and use Microsoft Roslyn to execute it. I never liked the fact that my simple filtering and looping was in an application, it should be scripted. Unfortunately, Roslyn does not yet support the XDocument type so I couldn’t easily convert it and I really didn’t want to do it in PowerShell cause I’m lazy...

Stat Helper

In the download you will find the following files:

  • _branches.config: Local checkout locations that statistics will be generated for.
  • _excludepaths.config: Path to exclude like merges from “trunk”.
  • _excludeusers.config: Users to exclude from the statistics.
  • GenerateLog.bat: Updates the checkout location and extracts the log.
  • GenerateStats.bat: Calls the external libraries to generates the statistics pages.
  • BrutalStatHelper.exe: Calls the batch files and performs filtering on log data.
  • BrutalStatHelper.cs: The source code for the filtering app.

 

Disclaimer: The code is not the best in the world and I don’t claim it to be production code by any means but it does the job as intended. Hopefully it gives people more ideas on improving the stats that get generated. What about making a contents page linking to all the stats index pages for example?

Instructions

  1. Download Stat Helper - Extract the files anywhere you want
  2. Install Java - You need this for both stats libraries
  3. Install command-line SVN - You need this to extract the log
  4. Edit _branches.config with the SVN checkout locations you want to generate stats for
  5. Edit _excludepaths.config with any paths you want to ignore
  6. Edit _excludeusers.config with any usernames you want to ignore
  7. Run BrutalStatHelper.exe to generate the stats

 

Stats will be generated in subdirectories of the directory you are running BrutalStatHelper.exe from. Open up index.html for StatSVN and more\index.html for SvnStat info from their respective directories when the process is complete.

Extra Information

Check out the additional options available for each library. The helper will get you going quickly but it’s up to you to investigate more and see what you can get out of generating statistics.

Call the helper from a Windows Scheduled Task or during an automated build (CI) to keep the stats fresh.

Start looking at and analyzing more statistics. I use RescueTime to gather statistics about my daily work and like any statistical analysis, it highlights areas of strength and weakness where you may not normally be able to see it.

WARNING: When I introduced this into the workplace it was greeted with interest from management but major apprehension from co-workers. A lot of people don’t like the “big brother” aspect and because the data could be skewed or misinterpreted.

Download Stat Helper - includes source code and both statistics libraries.