code_churn/churn_core.pl
author William Roberts <williamr@symbian.org>
Thu, 25 Feb 2010 22:46:41 +0000
changeset 173 048763260c9e
parent 158 27cf0a88d449
permissions -rw-r--r--
v0.3 of comvert_to_epl.py - writes a zip file containing the updated files, unless --nozip is specified Assumes that "zip.exe" is in the path.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     1
#!perl -w
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     2
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     8
#
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    11
# 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    12
# Contributors:
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    13
#
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    14
# Description:
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    15
#
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    16
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    17
use strict;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    18
use File::Find;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    19
use File::Copy;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    20
use Cwd;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    21
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    22
sub diffstat();
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    23
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    24
my $Logs_Dir = $ARGV[0];
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    25
my $dir_left = $ARGV[1];
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    26
my $dir_right = $ARGV[2];
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    27
my $dir_tmp_left = $ARGV[0].'\\'.$ARGV[1];
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    28
my $dir_tmp_right = $ARGV[0].'\\'.$ARGV[2];
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    29
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    30
print "left changeset $dir_left\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    31
print "right chnageset $dir_right\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    32
mkdir $dir_tmp_left;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    33
mkdir $dir_tmp_right;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    34
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    35
# default inclusions from churn.pl are "*.cpp", "*.c", "*.cxx", "*.h", "*.hpp", "*.inl" 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    36
my @file_pattern=('\.cpp$','\.c$','\.hpp$','\.h$','\.inl$','\.cxx$','\.hrh$');
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    37
my $totallinecount=0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    38
my $countcomments=0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    39
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    40
if (! -d $Logs_Dir)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    41
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    42
    die("$Logs_Dir does not exist \n");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    43
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    44
158
27cf0a88d449 Made the '-mirror' switch optional
Chetan Kapoor <chetank@symbian.org>
parents: 49
diff changeset
    45
#$dir_left =~ m/^(\w+)\.[0-9a-fA-F]+/;
27cf0a88d449 Made the '-mirror' switch optional
Chetan Kapoor <chetank@symbian.org>
parents: 49
diff changeset
    46
$dir_right =~ m/^(\w+)\.[0-9a-fA-F]+/;
49
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    47
my $package_name = $1;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    48
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    49
$dir_left =~ m/^\w+\.([0-9a-fA-F]+)/;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    50
my $changeset_left = $1;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    51
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    52
$dir_right =~ m/^\w+\.([0-9a-fA-F]+)/;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    53
my $changeset_right = $1;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    54
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    55
print "\nWorking on package: $package_name\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    56
print "\nProcessing $dir_left\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    57
find(\&process_files, $dir_left);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    58
#DEBUG INFO:
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    59
print "\nTotal linecount for changed files in $dir_left is $totallinecount\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    60
my $code_size_left = $totallinecount;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    61
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    62
$totallinecount=0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    63
print "\nProcessing $dir_right\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    64
find(\&process_files, $dir_right);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    65
#DEBUG INFO:
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    66
print "\nTotal linecount for changed files in $dir_right is $totallinecount\n";    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    67
my $code_size_right = $totallinecount;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    68
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    69
my @diffs;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    70
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    71
if (-d $dir_tmp_left && -d $dir_tmp_left)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    72
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    73
	@diffs = `diff -r -N $dir_tmp_left $dir_tmp_right`;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    74
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    75
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    76
my $changed_lines=@diffs;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    77
my $diffsfile = $Logs_Dir.'\\'."dirdiffs.out";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    78
open (DIFFS, ">$diffsfile");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    79
print DIFFS @diffs;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    80
close (DIFFS);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    81
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    82
diffstat();
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    83
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    84
$dir_tmp_left =~ s{/}{\\}g;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    85
$dir_tmp_right =~ s{/}{\\}g;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    86
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    87
if (-d $dir_tmp_left)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    88
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    89
	system("rmdir /S /Q $dir_tmp_left");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    90
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    91
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    92
if (-d $dir_tmp_right)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    93
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    94
system("rmdir /S /Q $dir_tmp_right");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    95
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    96
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    97
unlink $diffsfile;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    98
unlink "$Logs_Dir\\line_count_newdir.txt";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    99
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   100
print "\n** Finished processing $package_name **\n\n\n\n\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   101
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   102
exit(0);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   103
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   104
sub diffstat()
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   105
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   106
open (DIFFSFILE,"$diffsfile");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   107
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   108
my $curfile = "";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   109
my %changes = ();
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   110
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   111
while (<DIFFSFILE>)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   112
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   113
	my $line = $_;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   114
				# diff -r -N D:/mirror\fbf_churn_output\commsfw.000000000000\serialserver\c32serialserver\Test\te_C32Performance\USB PC Side Code\resource.h 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   115
				# diff -r <anything><changeset(12 chars)><slash><full_filename><optional_whitespace><EOL>
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   116
	if ($line =~ m/^diff -r.*\.[A-Fa-f0-9]{12}[\/\\](.*)\s*$/)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   117
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   118
		$curfile = $1;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   119
		#DEBUG INFO:
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   120
		#print "\t$curfile\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   121
		if (!defined $changes{$curfile})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   122
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   123
			$changes{$curfile} = {'a'=>0,'c'=>0,'d'=>0,'filetype'=>'unknown'};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   124
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   125
		
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   126
		$curfile =~ m/\.(\w+)$/g;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   127
				
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   128
		#if filetype known...
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   129
		my $filetype = $+;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   130
		
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   131
		$changes{$curfile}->{'filetype'}=uc($filetype);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   132
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   133
	elsif ($line =~ m/^(\d+)(,(\d+))?(d)\d+(,\d+)?/)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   134
	{	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   135
		if (defined $3)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   136
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   137
			$changes{$curfile}->{$4} += ($3-$1)+1;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   138
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   139
		else
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   140
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   141
			$changes{$curfile}->{$4}++;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   142
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   143
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   144
	elsif ($line =~ m/^\d+(,\d+)?([ac])(\d+)(,(\d+))?/)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   145
	{	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   146
		if (defined $5)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   147
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   148
			$changes{$curfile}->{$2} += ($5-$3)+1;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   149
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   150
		else
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   151
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   152
			$changes{$curfile}->{$2}++;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   153
		}	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   154
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   155
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   156
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   157
close (DIFFSFILE);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   158
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   159
my %package_changes = ("CPP"=>0, "H"=>0, "HPP"=>0, "INL"=>0, "C"=>0, "CXX"=>0,"HRH"=>0,);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   160
my %package_deletions = ("CPP"=>0, "H"=>0, "HPP"=>0, "INL"=>0, "C"=>0, "CXX"=>0,"HRH"=>0,);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   161
my %package_additions = ("CPP"=>0, "H"=>0, "HPP"=>0, "INL"=>0, "C"=>0, "CXX"=>0,"HRH"=>0,);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   162
my $package_churn = 0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   163
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   164
for my $file (keys %changes)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   165
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   166
	$package_changes{$changes{$file}->{'filetype'}} += $changes{$file}->{'c'};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   167
	$package_deletions{$changes{$file}->{'filetype'}} += $changes{$file}->{'d'};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   168
	$package_additions{$changes{$file}->{'filetype'}} += $changes{$file}->{'a'};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   169
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   170
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   171
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   172
#DEBUG INFO: For printing contents of hashes containing per filetype summary
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   173
#print "\n\n\n\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   174
#print "package_changes:\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   175
#print map { "$_ => $package_changes{$_}\n" } keys %package_changes;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   176
#print "\n\n\n\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   177
#print "package_deletions:\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   178
#print map { "$_ => $package_deletions{$_}\n" } keys %package_deletions;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   179
#print "\n\n\n\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   180
#print "package_additions:\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   181
#print map { "$_ => $package_additions{$_}\n" } keys %package_additions;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   182
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   183
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   184
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   185
my $overall_changes = 0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   186
for my $filetype (keys %package_changes)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   187
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   188
	$overall_changes += $package_changes{$filetype};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   189
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   190
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   191
my $overall_deletions = 0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   192
for my $filetype (keys %package_deletions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   193
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   194
	$overall_deletions += $package_deletions{$filetype};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   195
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   196
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   197
my $overall_additions = 0;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   198
for my $filetype (keys %package_additions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   199
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   200
	$overall_additions += $package_additions{$filetype};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   201
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   202
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   203
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   204
$package_churn = $overall_changes + $overall_additions;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   205
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   206
print "\n\n\n\nSummary for Package: $package_name\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   207
print "-------------------\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   208
print "Changesets Compared: $dir_left and $dir_right\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   209
#print "Code Size for $dir_left = $code_size_left lines\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   210
#print "Code Size for $dir_right = $code_size_right lines\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   211
print "Total Lines Changed = $overall_changes\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   212
print "Total Lines Added = $overall_additions\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   213
print "Total Lines Deleted = $overall_deletions\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   214
print "Package Churn = $package_churn lines\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   215
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   216
my @header = qw(filetype a c d);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   217
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   218
my $outputfile = $Logs_Dir.'\\'."$package_name\_diffstat.csv";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   219
open(PKGSTATCSV, ">$outputfile") or die "Coudln't open $outputfile";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   220
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   221
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   222
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   223
print PKGSTATCSV " SF CODE-CHURN SUMMARY\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   224
print PKGSTATCSV "Package: $package_name\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   225
print PKGSTATCSV "Changesets Compared: $dir_left and $dir_right\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   226
#print PKGSTATCSV "Code Size for $dir_left = $code_size_left lines\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   227
#print PKGSTATCSV "Code Size for $dir_right = $code_size_right lines\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   228
print PKGSTATCSV "Total Lines Changed = $overall_changes\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   229
print PKGSTATCSV "Total Lines Added = $overall_additions\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   230
print PKGSTATCSV "Total Lines Deleted = $overall_deletions\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   231
print PKGSTATCSV "Package Churn = $package_churn lines\n\n\n\n\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   232
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   233
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   234
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   235
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   236
# print the header
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   237
print PKGSTATCSV "FILENAME,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   238
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   239
foreach my $name (@header)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   240
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   241
  if ($name eq 'filetype')
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   242
  {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   243
	print PKGSTATCSV uc($name).",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   244
  }  
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   245
  elsif ($name eq 'a')
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   246
 {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   247
	print PKGSTATCSV "LINES_ADDED,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   248
 }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   249
  elsif ($name eq 'c')
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   250
 {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   251
	print PKGSTATCSV "LINES_CHANGED,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   252
 }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   253
  elsif ($name eq 'd')
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   254
 {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   255
	print PKGSTATCSV "LINES_DELETED,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   256
 }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   257
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   258
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   259
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   260
print PKGSTATCSV "\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   261
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   262
foreach my $file (sort keys %changes)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   263
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   264
  print PKGSTATCSV $file.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   265
  foreach my $key (@header)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   266
  {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   267
    if(defined $changes{$file}->{$key})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   268
    {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   269
      print PKGSTATCSV $changes{$file}->{$key};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   270
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   271
    print PKGSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   272
  }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   273
  print PKGSTATCSV "\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   274
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   275
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   276
close (PKGSTATCSV);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   277
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   278
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   279
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   280
my $diffstat_summary = $Logs_Dir.'\\'."diffstat_summary.csv";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   281
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   282
if (-e $diffstat_summary)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   283
{ 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   284
	open(DIFFSTATCSV, ">>$diffstat_summary") or die "Coudln't open $outputfile";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   285
	print DIFFSTATCSV "$package_name,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   286
	print DIFFSTATCSV "$changeset_left,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   287
	print DIFFSTATCSV "$changeset_right,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   288
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   289
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   290
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   291
	foreach my $filetype (sort keys %package_changes)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   292
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   293
		if(defined $package_changes{$filetype})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   294
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   295
		  print DIFFSTATCSV $package_changes{$filetype}.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   296
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   297
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   298
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   299
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   300
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   301
	foreach my $filetype (sort keys %package_additions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   302
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   303
		if(defined $package_additions{$filetype})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   304
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   305
		  print DIFFSTATCSV $package_additions{$filetype}.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   306
		  
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   307
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   308
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   309
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   310
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   311
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   312
	foreach my $filetype (sort keys %package_deletions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   313
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   314
		if(defined $package_deletions{$filetype})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   315
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   316
		  print DIFFSTATCSV $package_deletions{$filetype}.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   317
		  #print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   318
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   319
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   320
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   321
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   322
	print DIFFSTATCSV "$overall_changes,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   323
	print DIFFSTATCSV "$overall_additions,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   324
	print DIFFSTATCSV "$overall_deletions,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   325
	print DIFFSTATCSV "$package_churn,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   326
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   327
	print DIFFSTATCSV "\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   328
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   329
	close (DIFFSTATCSV);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   330
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   331
else
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   332
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   333
	open(DIFFSTATCSV, ">$diffstat_summary") or die "Couldn't open $outputfile";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   334
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   335
	# print the header
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   336
	print DIFFSTATCSV "PACKAGE_NAME,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   337
	print DIFFSTATCSV "LEFT_CHANGESET,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   338
	print DIFFSTATCSV "RIGHT_CHANGESET,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   339
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   340
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   341
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   342
	foreach my $name (sort keys %package_changes)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   343
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   344
		print DIFFSTATCSV $name." CHANGES,";    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   345
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   346
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   347
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   348
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   349
	foreach my $name (sort keys %package_additions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   350
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   351
		print DIFFSTATCSV $name." ADDITIONS,";    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   352
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   353
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   354
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   355
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   356
	foreach my $name (sort keys %package_deletions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   357
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   358
		print DIFFSTATCSV $name." DELETIONS,";    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   359
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   360
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   361
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   362
	print DIFFSTATCSV "PACKAGE_CHANGES,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   363
	print DIFFSTATCSV "PACKAGE_ADDITIONS,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   364
	print DIFFSTATCSV "PACKAGE_DELETIONS,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   365
	print DIFFSTATCSV "PACKAGE_CHURN,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   366
	print DIFFSTATCSV "\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   367
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   368
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   369
	print DIFFSTATCSV "$package_name,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   370
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   371
	print DIFFSTATCSV "$changeset_left,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   372
	print DIFFSTATCSV "$changeset_right,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   373
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   374
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   375
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   376
	foreach my $filetype (sort keys %package_changes)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   377
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   378
		if(defined $package_changes{$filetype})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   379
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   380
		  print DIFFSTATCSV $package_changes{$filetype}.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   381
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   382
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   383
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   384
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   385
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   386
	foreach my $filetype (sort keys %package_additions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   387
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   388
		if(defined $package_additions{$filetype})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   389
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   390
		  print DIFFSTATCSV $package_additions{$filetype}.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   391
		  
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   392
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   393
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   394
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   395
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   396
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   397
	foreach my $filetype (sort keys %package_deletions)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   398
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   399
		if(defined $package_deletions{$filetype})
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   400
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   401
		  print DIFFSTATCSV $package_deletions{$filetype}.",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   402
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   403
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   404
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   405
	#print DIFFSTATCSV ",";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   406
	print DIFFSTATCSV "$overall_changes,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   407
	print DIFFSTATCSV "$overall_additions,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   408
	print DIFFSTATCSV "$overall_deletions,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   409
	print DIFFSTATCSV "$package_churn,";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   410
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   411
	print DIFFSTATCSV "\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   412
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   413
	close (DIFFSTATCSV);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   414
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   415
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   416
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   417
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   418
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   419
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   420
sub process_files() 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   421
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   422
    my $lfile = $_;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   423
    my $lfile_fullpath=$File::Find::name;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   424
    $lfile_fullpath =~ s#\/#\\#g;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   425
    #print "$lfile\t\tFull path $lfile_fullpath\n" ;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   426
    if (-f $lfile)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   427
    { 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   428
        foreach my $regpat (@file_pattern)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   429
        {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   430
            if (lc($lfile) =~ m/$regpat/)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   431
            {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   432
                $lfile  =~ s#\/#\\#g;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   433
                #print "Processing file $lfile (Matched $regpat) \n"; #ck
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   434
                #print `type $lfile`;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   435
                # We copy mathching files to a separate temp directory
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   436
                # so that the final diff can simply diff the full dir
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   437
                # Note :  RemoveNoneLOC routine edits the file in-situ.
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   438
                my $lfile_abs = cwd().'\\'.$lfile;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   439
                my $lfile_local = $Logs_Dir.'\\'.$lfile_fullpath;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   440
                makepath($lfile_local);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   441
                print "%";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   442
                copy($lfile_abs,$lfile_local);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   443
				$totallinecount += RemoveNonLOC( $lfile, $lfile_local, "newdir" );
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   444
            }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   445
        }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   446
    }   
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   447
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   448
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   449
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   450
sub makepath()
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   451
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   452
    my $absfile = shift; 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   453
    $absfile =~ s#\\#\/#g;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   454
    my @dirs = split /\//, $absfile;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   455
    pop @dirs;  # throw away the filename
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   456
    my $path = "";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   457
    foreach my $dir (@dirs)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   458
    {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   459
        $path = ($path eq "") ? $dir : "$path/$dir";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   460
        if (!-d $path)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   461
        {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   462
#          print "making $path \n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   463
          mkdir $path;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   464
        }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   465
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   466
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   467
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   468
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   469
sub RemoveNonLOC($$$) {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   470
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   471
    # Gather arguments
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   472
    my $file = shift;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   473
    my $original_file  = shift;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   474
    my $type_of_dir = shift;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   475
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   476
#    print("\nDebug: in ProcessFile, file is $file, full file + path is $original_file \n");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   477
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   478
	# Remove comments...
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   479
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   480
    # Set up the temporary files that will be used to perform the processing steps
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   481
    my $temp1File = $original_file."temp1";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   482
    my $temp2File = $original_file."temp2";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   483
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   484
    open(TEMP1, "+>$temp1File");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   485
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   486
    if (!($countcomments)) {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   487
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   488
     	# Remove any comments from the file
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   489
		my $original_file_string;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   490
     	open INPUT, "<", $original_file;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   491
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   492
			local $/ = undef;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   493
			$original_file_string = <INPUT>;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   494
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   495
		close INPUT;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   496
 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   497
     	my $dbl = qr/"[^"\\]*(?:\\.[^"\\]*)*"/s;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   498
        my $sgl = qr/'[^'\\]*(?:\\.[^'\\]*)*'/s;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   499
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   500
        my $C   = qr{/\*.*?\*/}s; # C style comments /*  */
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   501
        my $CPP = qr{//.*}; # C+ style comments //
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   502
        my $com = qr{$C|$CPP};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   503
        my $other = qr{.[^/"'\\]*}s; # all other '"
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   504
        my $keep = qr{$sgl|$dbl|$other};
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   505
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   506
     	#Remove the comments (need to turn off warnings on the next regexp for unititialised variable)
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   507
no warnings 'uninitialized';
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   508
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   509
        $original_file_string=~ s/$com|($keep)/$1/gom;  
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   510
        print TEMP1 "$original_file_string";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   511
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   512
use warnings 'uninitialized';
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   513
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   514
    else {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   515
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   516
        print("\n option --CountComments specified so comments will be included in the count\n");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   517
        #Just copy over original with comments still in it
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   518
		copy($original_file,$temp1File); 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   519
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   520
   	 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   521
    close(TEMP1);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   522
   	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   523
 	  
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   524
    # Remove blank lines...
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   525
#   print("\nDebug: Getting rid of blank lines in \n$temp1File to produce \n$temp2File \n");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   526
    open (TEMP1, "+<$temp1File"); # include lines + pre-processed code
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   527
    open (TEMP2, "+>$temp2File"); 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   528
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   529
    while (<TEMP1>) {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   530
		
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   531
        if (!(/^\s*\n$/)) { # if line isn't blank write it to the new file 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   532
        print TEMP2 $_;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   533
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   534
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   535
    close(TEMP1);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   536
    close(TEMP2);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   537
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   538
    #Copy the final file to the original file. This updated file will form the input to diff later.
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   539
    #todo dont need chmod now?
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   540
    chmod(oct("0777"), $original_file) or warn "\nCannot chmod $original_file : $!\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   541
#   print("\nCopying $temp2File\n to \n$original_file\n");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   542
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   543
    #system("copy /Y \"$temp2File\" \"$original_file\"") == 0
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   544
    #or print "\nERROR: Copy of $temp2File to $original_file failed\n";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   545
    copy($temp2File,$original_file);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   546
  	 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   547
    # Store original file size
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   548
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   549
    open(LINECOUNT, ">>$Logs_Dir\\line_count_$type_of_dir.txt");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   550
    open(SOURCEFILE, "<$original_file");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   551
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   552
    my @source_code = <SOURCEFILE>;
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   553
    print  LINECOUNT "\n$original_file   ";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   554
    my $linecount = scalar(@source_code);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   555
#	print  LINECOUNT scalar(@source_code);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   556
    print  LINECOUNT $linecount; 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   557
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   558
    close(LINECOUNT);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   559
    close(SOURCEFILE);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   560
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   561
    #system("del /F /Q $Logs_Dir\\line_count_$type_of_dir.txt");
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   562
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   563
    #Delete the temporary files
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   564
    unlink($temp1File);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   565
    unlink($temp2File);
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   566
       
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   567
    return $linecount;   
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   568
}