code_churn/churn_core.pl
author Simon Howkins <simonh@symbian.org>
Fri, 06 Nov 2009 12:10:52 +0000
changeset 99 5adea361d896
parent 49 c0d2a34bf681
child 158 27cf0a88d449
permissions -rw-r--r--
Bug 881: "Automatic creation of release note content broken by config change" Added a new option to allow the caller to specify where the publish location is. Minor improvements to formatting of output. Turned on warnings, and fixed most of those that appeared. Greatly simplified the checking of the script arguments. Removed code which was noted to be unnecessary, and was. Declared some variables more closely to the code that uses them.
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
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    45
$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
    46
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
    47
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    48
$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
    49
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
    50
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    51
$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
    52
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
    53
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    54
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
    55
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
    56
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
    57
#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
    58
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
    59
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
    60
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    61
$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
    62
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
    63
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
    64
#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
    65
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
    66
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
    67
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    68
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
    69
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    70
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
    71
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    72
	@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
    73
}
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
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
    76
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
    77
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
    78
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
    79
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
    80
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    81
diffstat();
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    82
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    83
$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
    84
$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
    85
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    86
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
    87
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    88
	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
    89
}
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
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
    92
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    93
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
    94
}
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
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
    97
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
    98
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
    99
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
   100
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   101
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
   102
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   103
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
   104
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   105
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
   106
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   107
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
   108
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
   109
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   110
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
   111
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   112
	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
   113
				# 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
   114
				# 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
   115
	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
   116
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   117
		$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
   118
		#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
   119
		#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
   120
		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
   121
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   122
			$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
   123
		}
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
		$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
   126
				
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   127
		#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
   128
		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
   129
		
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   130
		$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
   131
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   132
	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
   133
	{	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   134
		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
   135
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   136
			$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
   137
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   138
		else
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   139
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   140
			$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
   141
		}
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
	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
   144
	{	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   145
		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
   146
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   147
			$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
   148
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   149
		else
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   150
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   151
			$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
   152
		}	
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
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
   157
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   158
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
   159
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
   160
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
   161
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
   162
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   163
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
   164
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   165
	$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
   166
	$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
   167
	$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
   168
}
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
#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
   172
#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
   173
#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
   174
#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
   175
#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
   176
#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
   177
#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
   178
#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
   179
#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
   180
#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
   181
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
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
   185
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
   186
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   187
	$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
   188
}
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
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
   191
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
   192
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   193
	$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
   194
}
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
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
   197
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
   198
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   199
	$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
   200
}
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
$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
   204
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   205
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
   206
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
   207
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
   208
#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
   209
#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
   210
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
   211
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
   212
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
   213
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
   214
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   215
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
   216
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   217
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
   218
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
   219
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
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
   223
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
   224
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
   225
#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
   226
#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
   227
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
   228
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
   229
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
   230
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
   231
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
# 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
   236
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
   237
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   238
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
   239
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   240
  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
   241
  {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   242
	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
   243
  }  
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   244
  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
   245
 {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   246
	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
   247
 }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   248
  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
   249
 {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   250
	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
   251
 }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   252
  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
   253
 {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   254
	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
   255
 }
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
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
   260
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   261
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
   262
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   263
  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
   264
  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
   265
  {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   266
    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
   267
    {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   268
      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
   269
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   270
    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
   271
  }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   272
  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
   273
}
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
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
   276
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
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
   280
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   281
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
   282
{ 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   283
	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
   284
	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
   285
	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
   286
	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
   287
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   288
	#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
   289
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   290
	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
   291
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   292
		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
   293
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   294
		  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
   295
		}
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
	#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
   299
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   300
	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
   301
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   302
		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
   303
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   304
		  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
   305
		  
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
	#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
   310
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   311
	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
   312
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   313
		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
   314
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   315
		  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
   316
		  #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
   317
		}
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
	#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
   321
	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
   322
	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
   323
	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
   324
	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
   325
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   326
	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
   327
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   328
	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
   329
}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   330
else
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   331
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   332
	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
   333
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   334
	# 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
   335
	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
   336
	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
   337
	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
   338
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   339
	#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
   340
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   341
	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
   342
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   343
		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
   344
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   345
	#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
   346
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
	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
   349
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   350
		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
   351
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   352
	#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
   353
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
	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
   356
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   357
		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
   358
	}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   359
	#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
   360
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   361
	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
   362
	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
   363
	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
   364
	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
   365
	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
   366
	
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
	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
   369
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   370
	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
   371
	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
   372
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   373
	#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
   374
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   375
	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
   376
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   377
		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
   378
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   379
		  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
   380
		}
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
	#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
   384
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   385
	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
   386
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   387
		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
   388
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   389
		  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
   390
		  
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
	#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
   395
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   396
	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
   397
	{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   398
		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
   399
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   400
		  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
   401
		}
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
	#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
   405
	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
   406
	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
   407
	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
   408
	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
   409
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   410
	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
   411
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   412
	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
   413
}
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
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
   420
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   421
    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
   422
    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
   423
    $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
   424
    #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
   425
    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
   426
    { 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   427
        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
   428
        {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   429
            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
   430
            {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   431
                $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
   432
                #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
   433
                #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
   434
                # 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
   435
                # 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
   436
                # 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
   437
                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
   438
                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
   439
                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
   440
                print "%";
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   441
                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
   442
				$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
   443
            }
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
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
   450
{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   451
    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
   452
    $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
   453
    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
   454
    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
   455
    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
   456
    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
   457
    {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   458
        $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
   459
        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
   460
        {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   461
#          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
   462
          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
   463
        }
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
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
   469
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   470
    # 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
   471
    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
   472
    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
   473
    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
   474
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   475
#    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
   476
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   477
	# 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
   478
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   479
    # 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
   480
    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
   481
    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
   482
	
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   483
    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
   484
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   485
    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
   486
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   487
     	# 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
   488
		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
   489
     	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
   490
		{
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   491
			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
   492
			$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
   493
		}
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   494
		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
   495
 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   496
     	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
   497
        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
   498
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   499
        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
   500
        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
   501
        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
   502
        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
   503
        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
   504
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   505
     	#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
   506
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
   507
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   508
        $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
   509
        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
   510
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   511
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
   512
    }
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   513
    else {
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   514
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   515
        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
   516
        #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
   517
		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
   518
    }
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
    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
   521
   	
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
    # 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
   524
#   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
   525
    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
   526
    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
   527
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   528
    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
   529
		
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   530
        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
   531
        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
   532
	}
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
    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
   535
    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
   536
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   537
    #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
   538
    #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
   539
    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
   540
#   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
   541
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   542
    #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
   543
    #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
   544
    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
   545
  	 
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   546
    # 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
   547
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   548
    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
   549
    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
   550
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   551
    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
   552
    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
   553
    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
   554
#	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
   555
    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
   556
     
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   557
    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
   558
    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
   559
    
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   560
    #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
   561
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   562
    #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
   563
    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
   564
    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
   565
       
c0d2a34bf681 Creating "code_churn" directory in utilities, and adding perl scripts for code chrun tool
Chetan Kapoor <chetank@symbian.org>
parents:
diff changeset
   566
    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
   567
}