[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Number of lines of code changed between tags
From: |
Jerry Nairn |
Subject: |
RE: Number of lines of code changed between tags |
Date: |
Fri, 27 Apr 2001 10:45:20 -0700 |
>From: Keith Beattie [mailto:address@hidden
>Sent: Thursday, April 26, 2001 3:48 PM
>How can I find the total number of lines changed (for text files only)
>between two static tags for an entire module or subtree of the
>repository?
You can pipe the output from
cvs -nq diff -R -n -r tag1 -r tag2 subtree_path
through a perl script like this.
I have only used this on Solaris, so I can't vouch for it on any other
platform, but it ought to work fine.
If you use it, and modify it at all, I'd like to see your improvements.
Cheers,
Jerry
#!/usr/bin/perl -n
# Copyright 2001-2001 AdForce, Inc. This file is the exclusive property of
# AdForce Inc., and may not be used or altered without AdForce's express
# written permission.
# Jerry Nairn, AdForce Release Engineering, address@hidden
#
# This script is intended to parse the output of cvs diff commands
# The command should have the format:
# cvs -nq diff -R -n <date and revision args> <files and dirs>
#
$line = $_;
if ($line =~ /^cvs diff: (.*)$/) {
print "*** $1\n";
} elsif ($line =~ /^([acd])[0-9]+\s([0-9]+)$/) {
$mod = $1;
$num = $2;
if ( $mod eq "a" ) {
if ( $num > $dnum ) {
$csum += $dnum;
$asum += ( $num - $dnum );
} else {
$csum += $num;
$dsum += ( $dnum - $num );
}
$dnum = 0;
} elsif ( $mod eq "d" ) {
$dsum += $dnum;
$dnum = $num;
}
} elsif ($line =~ /^RCS file\: ${ENV{CVSROOT}}\/(.*)\,v$/) {
$newfilename = $1;
$dsum += $dnum;
if ( $filename ) {
$fileasums{$filename} = $asum;
$filedsums{$filename} = $dsum;
$filecsums{$filename} = $csum;
$filetotal{$filename} = ( $csum + $dsum + $asum );
print "$filename: ";
if ( $asum ) {
print "$asum added, ";
$overallasum += $asum;
};
if ( $dsum ) {
print "$dsum deleted, ";
$overalldsum += $dsum;
};
if ( $csum ) {
print "$csum changed, ";
$overallcsum += $csum;
};
print "$filetotal{$filename} lines total\n";
print " revision $oldrev{$filename} to revision
$newrev{$filename}\n";
$overalltotal += $filetotal{$filename};
}
$asum = $dsum = $csum = 0;
$filename = $newfilename;
} elsif ($line =~ /^diff -n -r([0-9\.]*) -r([0-9\.]*)\s*$/) {
$oldrev{$filename} = $1;
$newrev{$filename} = $2;
} else {
if ( $dnum ) {
$dsum += $dnum;
}
$dnum = 0;
}
if ( eof ) {
if ( ! $overallasum ) { $overallasum = 0; }
print "Total Added Lines = $overallasum\n";
if ( ! $overallcsum ) { $overallcsum = 0; }
print "Total Changed Lines = $overallcsum\n";
if ( ! $overalldsum ) { $overalldsum = 0; }
print "Total Deleted Lines = $overalldsum\n";
print "Total = $overalltotal\n";
}