views:

40

answers:

2

I'm using SVN with Google Code Project Hosting for a school project. As the codebase increases in size, I often find myself wondering questions like:

  • "who originally checked in this line of code?"
  • "who has been checking in the most code recently?"
  • "Of the final product, how much of it was written by Person X?"
  • "Which coder is best at adhering to the coding conventions?"

Is there any plugin available to do this? (If not, I would be interested in developing one myself. Any ideas on where to get started on that?)

We're using Visual Studio 2008 with the AnkhSVN plugin.

+7  A: 

Within Subversion itself, the command svn blame gives you author and revision information for each line of a file.

The external tool StatSVN is pretty good. It does most of what you want, including author stats. Adherence to code conventions is not covered. For that sort of thing you're better off with something like Sonar.

ire_and_curses
Good to know. If I have ankhSVN installed for Visual Studio, can I access SVN on the command line? If so, how?
Rosarch
@Rosarch - Sorry, can't help you there. I've never used Visual Studio. Or any SVN IDE plugin. Or for that matter, any IDE... ;)
ire_and_curses
TortoiseSVN can be used in addition to AnkhSVN, and has a graphical blame, or you can get a command-line win32 version from one of several sources here: http://subversion.apache.org/packages.html#windows If you attempt to use both Ankh and one of the others simultaneously, you may get lock issues, but as long as you finish any active operations with one before moving to the other, you'll be fine. I mix command-line and Tortoise all the time where I work. (Note that Tortoise's TSVNCache has occasionally been a little bit unhappy with that; I usually disable it.)
leander
A: 

The svn blame command gives you the author and revision for the last change for each line, and you can use the -r # option to look at the same information in an earlier revision. So to get the full history you have to loop:

  1. svn blame -r HEAD to get the most recent changes.
  2. Check for the line you're interested in to make sure it's present.
  3. Parse the revision numbers (all in the file or just in the range of lines you're interested in) and find the largest one.
  4. Back to 1 using the largest revision - 1 instead of HEAD.

You'll have trouble keeping track of the line across modifications, in general. I've written some tools that help with each step, but whenever I've needed to do this sort of thing I've had to do it manually, looking at the svn blame output at each stage to see how the code changed in each revision.

DougWebb
One of the Perforce clients had a nice scrollbar which you could grab and drag to traverse revisions, watching code pop in and out and change. I think there was even line coloring by age, relative to the current revision. I missed that tool quite a bit when I moved to another company using Subversion+TortoiseSVN.
leander
That sounds really cool. I don't think there's a way to do that quickly with svn, at least not while the repository is remote. Maybe if you've got the repository on the local machine and you use the admin API to access the history you could write an app which does that.
DougWebb