Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine change statistics between revisions

Tags:

svn

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

like image 235
R.D Avatar asked Nov 16 '08 18:11

R.D


3 Answers

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!

like image 166
Peter Bratton Avatar answered Oct 23 '22 05:10

Peter Bratton


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.

like image 39
coppro Avatar answered Oct 23 '22 06:10

coppro


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!

like image 23
Gadget Avatar answered Oct 23 '22 05:10

Gadget