Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count the number of changed or added lines in an SVN branch?

Tags:

svn

I would like to add up the number of line changes in an SVN branch so I can tell how far I have gone during a project from another side and estimate the probability of conflict when I merge it with trunk.

The way I can think of is to grab the unified diff and do some grep|wc -l hacks, but the problem is it's hard to separate different file types, for example, front-end source files (.css, .html) and back-end source files(.xml, .java)

like image 306
fwonce Avatar asked May 09 '12 13:05

fwonce


People also ask

How do I view changes in svn?

To get an overview of your changes, use the svn status command. You may use svn status more than any other Subversion command. If you run svn status at the top of your working copy with no arguments, it detects all file and tree changes you've made.

What is the use of svn diff command?

The svn diff command reveals the differences between your working copy and the copy in the master SVN repository.


1 Answers

Cosidering beginRev as the initial revision of the changeset you want to measure and endRev as the final revision:

svn diff --summarize -rbeginRev:endRev <URLtoBranch>

This will give you the output of files added, deleted and modified.

I you want more detail level you could parse the svn diff output through diffstat:

svn diff -rbeginRev:endRev <URLtoBranch> | diffstat

This will return an histogram of the changes with information for each file, and a summary of files changed, lines added and deleted.

like image 111
Diego Fernández Durán Avatar answered Sep 20 '22 19:09

Diego Fernández Durán