The following Perl code automates MS Visual Source Safe to get the stats on check-ins. The input should be a list of files from the output of my other script.
#!/usr/bin/perl -w
use strict;
# Read a list of check-ins and call 'ss Diff' to get what was checked-in
$ENV{'SSDIR'} = "<source safe network folder>";
my $project = "<project folder>";
my $checkInsFile = "<output from first perl script>";
# Read in check-ins from file
open( checkIns, $checkInsFile );
while( <checkIns> ) {
# Parse out the details from the check-in
my( $file, $ver, $use, $date, $com );
if( m/^(.*)\t(.*)\t(.*)\t(.*)\t(.*)$/ ) {
( $file, $ver, $use, $date, $com ) = ($1, $2, $3, $4, $5);
}
# Put any check for conditions here
# Check for some date range
# Check for some file pattern
# Check for some comment pattern
# Summed totals for this check-in
my $added = 0;
my $changed = 0;
my $deleted = 0;
# Special case version 1 to get the file line count of Version 1 (Check-in)
if( $ver == '1' ) {
# Get linecount for version 1 of file
my $command = "ss View \$/$project/$file -V$ver|";
open( ssView, $command );
while( <ssView> ) {
$added++;
}
close( ssView );
}
else {
# Open a Unix diff from version-1 to version
my $verMinus1 = $ver - 1;
my $command = "ss Diff -DU \$/$project/$file -V$verMinus1~$ver|";
open( ssDiff, $command );
while( <ssDiff> ) {
# Match for "number[a|d|c]number" at the start of a line
if( m/^(\d+),?(\d*)([acd])(\d+),?(\d*)$/ ) {
# Added
if( $3 eq "a" ) {
$added += ($5 gt "" ? $5 : $4) - $4 + 1;
}
# Changed
if( $3 eq "c" ) {
$changed += ($5 gt "" ? $5 : $4) - $4 + 1;
}
# Deleted
if( $3 eq "d" ) {
$deleted += ($5 gt "" ? $5 : $4) - $4 + 1;
}
}
}
close( ssDiff );
}
# Print check-in details + edit details
print "$file\t$ver\t$use\t$date\t$added\t$changed\t$deleted\t$com\n";
#print "Totals for ${file};$ver ($use) on $date added: $added changed: $changed deleted: $deleted\n";
}
# Done
exit 0;
