tags:

views:

322

answers:

2

Given 2 file revisions I want to know how many lines were added/modified/deleted. I want to have this information for the entire repository of thousand of files. Please point me to a script or tool as I am a total svn newbie

I am working on windows

Sample output

File~NewRevision~OldRevision~Added~Modified~Deleted

file1.c~#11~#10~1~2~0

file1.c~#2~#1~2~2~0

+3  A: 

Subversion has a very nice diff tool integrated within it. I would use a command such as:

svn diff -rOldRevision:NewRevision URL

where URL is the URL of your repository (for instance, http://www.mycode.org/svn/trunk). This won't format the diff output in the form you are looking for, but it will show how each file has been changed between the two revision numbers.

For your formatting, you could use a grep to count how many additions and subtractions occur in each file.

Hope this helps!

jordan002
+1  A: 

SVN (or any similar tool) doesn't distinguish between a modified line and a line that was deleted and replaced with something else. That said, however, your best bet would be to get a diff (as jordan002 said) and then search for lines beginning with + or -. For every -, a line was deleted, for every +, a line was added (you can make svn ignore whitespace on the diff with svn diff --diff-cmd diff -x -w -x -u -rOldRev:NewRev on a system with Unix diff installed). Then, you can compare them. The unified diff will be organized into hunks (different parts of the file that were changed) separated by lines starting with @@, and you could, for each hunk, say that the lesser of lines deleted and added was the number of lines changed, and for each added line more than removed in a hunk, a line was added, and for each line removed more than added in a hunk, a line was deleted. Not perfect, but relatively good for your assessment.

One more note: if you are using this to evaluate programmers, be careful. LOC isn't a great method of measuring relative effectiveness.

coppro
Would someone mind scripting either of the responses above for me? I have to get the data for at least a 100 files. [Please advise if I should advertise this as a paid task]
DotDot