views:

474

answers:

2

How can I get a fully recursive svn blame report for all non-binary files in a branch, where the output is in a single file in xml format and includes revision, date, author, filename & path, and the text of the line of the file itself? The entire output needs to be in a single file. It will be executed as part of the build via a CCNet instance.

Available tools are the latest stable release of nant and nantcontrib, msbuild, and latest command line svn.

Here's some of the issues I have run into: Command line svn blame command does not support directory recursion. Blame's --xml option does not include the actual text of each line, though it does have everything else. By default nantcontrib is passing the --quiet parameter (contrary to the task reference), which is not supported on the blame command. Nantcontrib svn task may not accept the --xml parameter.

+1  A: 

The simple answer is that there isn't any easy way to do this. The best, most correct way would be to write your own svn client (or extend the existing one) so that it has the functionality you need. Hardly trivial.

There's also a wrong way to do it, which also involves writing code. Don't do this:

find . -type f | grep -v .svn | xargs svn blame > line_data
find . -type f | grep -v .svn | xargs svn --xml blame > xml_data

You could script the two svn commands together to avoid running find twice, but this will still be excruciatingly slow. To add insult to injury, you'll then have to parse the two files yourself to add the actual source lines into the xml data.

Sadly, I think this is the extent of the support for what you want with the standard svn client, and I can't find any other clients that do things better (some don't even support blame).

Adam Bellaire
+1  A: 

I do not know what OS you are using. But you can try using a simple FOR loop and the command "svn ls -R" to recursively list all the files in your branch (workspace/url) and then pipe it to "svn blame --xml".

I have tried this out in my SVN command line prompt and it works fine (Windows XP, SVN 1.4.4). The command I used is as follows:

FOR /F "usebackq delims==" %i IN (svn ls -R http://myurl/mybranch) DO @svn blame --xml %i

Note:You can avoid some "url not found" type of errors if you type this command in a workspace (reflecting your branch root) and use the 'svn ls -R` instead of the url in the above command.

Hope this helps.

Critical Skill
The line information is not included this way. Thanks though.
Josh Buedel