Question

I've spent most of the day making what are basically some housekeeping changes to the codebase of one of our projects (replacing all System.out.println() calls with log4j).

I'm kind of curious how many lines of code I've updated with this set of changes.

Is there anyway with cvs diff or another command to get an accurate count of how many lines have changed?

I've tried

cvs diff -b -B -R

to get all of the changes in the working directory (and recursively the subdirectories), but for each file changed it also prints out file/version information, which makes just counting the lines of output useless.

Any ideas?

Was it helpful?

Solution

Filter out extra lines from the diff output and then count the lines.

For example, grep only lines starting with < or >

cvs diff -b -B -R | egrep '^<|>' | wc -l

OTHER TIPS

The diffstat utility is a nice tool for getting some simple metrics from the output of cvs, svn or other diffs.

You can simply pipe output of cvs diff to diffstat.

What about verify that you've changed all instances with something like:

find . | egrep -v -e '(CVS|<other patterns you don't want>)' | \
    xargs egrep -e 'System\.out\.println[(][)]' | wc -l

that should give you zero.

Then replacing the regex in the second egrep with 'log4j' should have wc -l returning the number of lines you've changed.

HTH.

cheers,

Rob

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top