I needed to generate a sortable list of all the changes made to a branch in subversion. svn log dumps a list, but is very difficult to sort, based on users, time, etc. I wrote a script based on a ruby script to dump the data in a comma separated format, that can then me loaded in Excel to analyze. Here is the script
# This script allows the svn log to be dumped as a comma separated list so that the data can be analyzed in excel
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
username = ARGV[1]
svnUrl = ARGV[0]
#puts "Requesting SVN log, this may take a bit."
doc = IO.popen("svn log --xml -v --stop-on-copy " + svnUrl) do |f|
Hpricot.XML(f)
end
entries = doc.search("logentry").find_all do |entry|
if(username != nil)
(entry/"author").innerHTML == username
else
true
end
end
puts "Revision,Author,Date,Action,Path,Message"
entries.each do |entry|
revision = entry.attributes["revision"]
author = (entry/"author").innerHTML
date = (entry/"date").innerHTML
msg = (entry/"msg").innerHTML
paths = (entry/"paths").search("/path")
paths.each do |path|
action = path.attributes["action"]
puts "#{revision},#{author},#{date}, #{action}, #{ path.innerHTML}, #{msg.gsub("\n", " ")}"
end
end
Friday, June 13, 2008
Subversion: Generating a sortable list of changes made to a branch
Posted by
Dinesh Bhat
at
4:03 PM
Labels: ruby, subversion, svn
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment