tags:

views:

229

answers:

3

I have a professor that doesn't understand source control very well. He asked us to use comments to determine who wrote each line of code. Most of the class is using email as version control and Visual C++ as the language which leads to a mess of comments, carets and generated code. My group is using subversion and C# and I would prefer to get the history from the repository instead of cluttering the code with comments on every line.

I need a way to generate a viewable history of all checkins which shows how much of the source each user modified.

A format like this would be nice

Andy
/trunk/doc/file.txt (57%)
/trunk/project/app.h (100%)

Brian
/trunk/doc/file.txt (43%)
/trunk/project/app.cpp (60%)

Jeff
/trunk/project/app.cpp (40%)

How would I go about this? Does BASH have enough power to do this or should I use python? (I would generate the diff on a linux system)

+5  A: 

It seems to me you want something like svn blame.

You might want some post processing if you want percentages. And you'll also have to worry about modifications counting to the last person who touched the line.

Douglas Leeder
brilliant. I didn't know that command! This makes it much easier than using diffs.
AndreasT
+1  A: 

To answer a second part of your question, if you know Python (or similar), you'll find libraries to handle the SVN integration for you. That will be simpler than talking to SVN via bash and trying to interrogate the output from the SVN executables.

e.g. see Pysvn

Brian Agnew
+1  A: 

It's not ready to use solution, but I leave it to you :)

For each file, i.e. with something similar to:

for i in `ls -1`; do svn blame...; done

run:

svn blame full_svn_path_to_file |tr -s '\040' |tr '\040' ';'|cut -d \; -f 3|sort -u

this give you unique list of users who change file full_svn_path_to_file.

Using this list and wc and for commands you can try to calculate percentages...

Good luck!

Grzegorz Gierlik
Thanks, a partial solution gives me a place to start. A ready to use script takes some of the fun out of it. ;)
epochwolf