mabn
mabn

Reputation: 2523

svn - frequency of commits per file or directory

I'm looking for something which would show how often commits to svn modify files. I want to be able to see which files change often and how often. Preferably also the "report" should be grouped by directory, to be able to see frequency of changes per project.

Which tool provides such ability?

(if that matters - I'm also using maven and the language ism mostly java)

Upvotes: 3

Views: 976

Answers (3)

kohlerm
kohlerm

Reputation: 2624

There should not be $ in the line "while read $file" e.g it should be "while read file". Otherwise it works fine!

Upvotes: 0

David W.
David W.

Reputation: 107040

There's no standard tool to do this in Subversion. However, I can see one possible way of doing it, but it might take a while.

First, you need to generate a listing of all files in your repository. This should do it:

$ svn ls -R $REPO

Then you could use that as input and somehow generate a report from each file:

$ svn ls -R $REPO | while read $file
do
    here be dragons
done

We need to get rid of files (now BASH and Kornshell specific):

$ svn ls -R $REPO | while read $file
do
    [[ $file == */ ]] && continue
    here be dragons
done

Then, we need to figure out how to count all of the changes. The svn log should do it. If we count all lines that are composed of nothing but dashes, that should give us a count:

$ svn ls -R $REPO | while read $file
do
    [[ $file == */ ]] && continue
    count=$(svn log $REPO/$file | grep "^--*$" | wc -l)
    echo "$REPO/$file: $count"
done

There are a few issues with this:

  • I'm assuming that you're going from the root of the repository. If not, you may have to account for the directory entries.
  • There's a problem of files with wacky white space in their names. This will work if files don't have white space (I'm assuming that your source files don't) or that have a single space and don't have spaces in the front or end of their names. However, double spaces, tabs, etc. will be problematic.
  • This is going to be slow, and there's no real report, just a list of files and a count.
  • This doesn't handle deleted files. If a file has been deleted from the repository, it won't be listed in this program.
  • This program is dog slow. In my tests, it takes around a second for each file. Start it, get lunch, have a cup of coffee. Maybe ride down to Atlantic City and play a few hands of craps. It should be done by the time you get back.

It's a beginning. You could limit the range of dates via the -r parameter in the svn log. You might not care if a file had a lot of revisions if most of those revisions came from two years ago. And, this is probably the limit of a shell script. The logic could be ported over to Python or Perl and more done there.

Upvotes: 2

Ashwin Bhargava
Ashwin Bhargava

Reputation: 76

Although there are SVN Internal commands to generate reports, I would advice to try using FishEye tool from Atlassian. Its a paid tool, but gives extensive details, on how many files commited by specific user, which file committed how many times and also gives reports in graphical format.

Upvotes: 1

Related Questions