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
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!
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.
I also tried to solve task such as "how many lines were removed, added or just changed in selected period of time". So I wrote simple shell script (for Linux only). It gathers some sipmle statistics about code modifications. More details and shared script you may find here:
http://cyber-fall.blogspot.com/2011/10/tools-linux-svn-generate-statistic.html
Hope it will help to you and to others!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With