Pulling Subversion Logs for a Single User
There are many times during a project where I use the svn log command in order to see what has changed and to get a feel for the pace of development. It's also great when you're dealing with clients; you're only one command away from telling an inquisitive client exactly who did what task and when they did them. However, svn log is missing one important feature -- the ability to filter by a particular username. When I asked in #svn on freenode, they suggested I use the --xml option and parse the resulting output.
The following is what I came up with. It's a ruby script that uses the delightful Hpricot gem to parse the xml. It takes one argument, the subversion username that you wish to retrieve the logs for. I hope that it's useful for someone else! You can curl it from http://pastie.textmate.org/197763.txt if that makes it easier, too.
-
#!/usr/bin/ruby
-
require 'rubygems'
-
require 'hpricot'
-
-
username = ARGV[0]
-
if username.nil? || username == ""
-
puts "Please specify the username to cull log entries for."
-
exit
-
end
-
-
puts "Requesting SVN log, this may take a bit."
-
-
doc = IO.popen("svn log --xml") do |f|
-
Hpricot.XML(f)
-
end
-
-
entries = doc.search("logentry").find_all do |entry|
-
(entry/"author").innerHTML == username
-
end
-
-
entries.each do |entry|
-
revision = entry.attributes["revision"]
-
author = (entry/"author").innerHTML
-
date = (entry/"date").innerHTML
-
msg = (entry/"msg").innerHTML
-
-
puts "r#{revision} - #{author}"
-
puts "#{date}"
-
puts "#{msg}"
-
puts "-"*80
-
end

BugZilla 3.0 stable was recently released