releaseAutomation/mercurialComparison.pl
author Simon Howkins <simonh@symbian.org>
Fri, 06 Nov 2009 15:21:20 +0000
changeset 101 5407bb741e43
parent 86 97b833888afe
child 106 b51d77004ea8
permissions -rw-r--r--
Changed the hard-coded default for the releases location, so at least tonight's candidate build will work OK.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     1
#!perl -w
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     2
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     8
#
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    11
# 
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    12
# Contributors:
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    13
#
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    14
# Description:
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    15
# Automates the creation of part of the PDK Release Notes: "Mercurial Comparison with PDK XXXXX"
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    16
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    17
use strict;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    18
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    19
use FindBin;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    20
$FindBin::Bin =~ s{/}{\\}g;;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    21
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
my $bomInfoFile = shift or die "First argument must be BOM file for build being built/released\n";
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
my $previousPdkLabel = shift or die  "Second argument must be hg label to compare against\n";
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    24
my $detailsTsvFilename = shift or die "Third argument must be filename to write detailed TSV data into\n";
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    25
defined shift and die "No more than three arguments please\n";
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
# Use external scripts to get the raw data and produce the CSV summary (to go into Excel, etc)
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    28
my @pkgErrors = `perl $FindBin::Bin\\..\\clone_packages\\clone_all_packages.pl -packagelist $bomInfoFile -exec -- hg status -A --rev $previousPdkLabel 2>&1 | perl $FindBin::Bin\\..\\williamr\\summarise_hg_status.pl 2>&1 > $detailsTsvFilename`;
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    29
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    30
# The redirection above means that we capture STDERR from summarise_hg_status,
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
# which lists packages for which it was unable to generate any data
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    32
# 
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    33
# It's captured because that happens either because it's a new package or has
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    34
# moved from SFL -> EPL or we've reverted to using the MCL instead of the FCL
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    35
# (in which case it's dealt with in another part of the release notes) or it
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    36
# just hasn't had any changes since the last release
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    37
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    38
# Input from TSV file
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    39
my @rawData;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    40
open my $fh, "<", $detailsTsvFilename;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    41
my @columns;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    42
foreach my $line (<$fh>)
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    43
{
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    44
	chomp $line;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    45
	my @values = split "\t", $line;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    46
	if (!@columns)
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    47
	{
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    48
		@columns = @values;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    49
	}
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    50
	else
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    51
	{
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    52
		my %lineData;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    53
		@lineData{@columns} = @values;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    54
		push @rawData, \%lineData;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    55
	}
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    56
}
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    57
close $fh;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    59
# Pivot
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    60
my %cookedData;
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
foreach my $datum (@rawData)
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    62
{
55
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    63
	# Accumulate the total number of files in the old revision of the pkg
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    64
	$cookedData{$datum->{Package}}->{totalFiles} += $datum->{Count} unless $datum->{Change} eq "A";
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    65
	$cookedData{$datum->{Package}}->{same} += $datum->{Count} if $datum->{Change} eq "same";
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    66
	$cookedData{$datum->{Package}}->{addRemove} += $datum->{Count} if $datum->{Change} =~ m{^[AR]$};
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
}
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    68
# Add the "exception" packages
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    69
foreach my $package (@pkgErrors)
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    70
{
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    71
	chomp $package;
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    72
	$package =~ s{No valid comparison for }{};
82
bbe9783cf993 Updated wiki markup output so that lines don't run together (now a list).
Simon Howkins <simonh@symbian.org>
parents: 57
diff changeset
    73
	$cookedData{$package}->{exception} = "* Package is brand new, or converted from SFL -> EPL, or has transitioned from FCL back to MCL (not covered in this section)\n";
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    74
}
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
# Cut-off for "interesting" packages
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    77
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
foreach my $package (keys %cookedData)
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
{
55
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    80
	# Ensure items are defined
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    81
	$cookedData{$package}->{totalFiles} |= 1;
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    82
	$cookedData{$package}->{same} |= 0;
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    83
	$cookedData{$package}->{addRemove} |= 0;
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    84
	$cookedData{$package}->{percentChurn} = 100 * (1 - ($cookedData{$package}->{same} / $cookedData{$package}->{totalFiles}));
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    85
	$cookedData{$package}->{exception} |= "";
55
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    86
	
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    87
	# More than N files added + removed
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    88
	next if $cookedData{$package}->{addRemove} >= 400;
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    89
	# More than M% churn
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    90
	next if $cookedData{$package}->{percentChurn} > 30;
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    91
	# Unable to compare at all
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
    92
	next if $cookedData{$package}->{exception};
55
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    93
	# Nothing interesting about this package
67168a24b405 Made test for interesting packages consider % files churned. >30% is
Simon Howkins <simonh@symbian.org>
parents: 49
diff changeset
    94
	delete $cookedData{$package};
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    95
}
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    96
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    97
# Output
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    98
foreach my $package (sort keys %cookedData)
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    99
{
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   100
	print <<"EOT";
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   101
=== $package ===
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   102
82
bbe9783cf993 Updated wiki markup output so that lines don't run together (now a list).
Simon Howkins <simonh@symbian.org>
parents: 57
diff changeset
   103
* $cookedData{$package}->{addRemove} files added/removed
bbe9783cf993 Updated wiki markup output so that lines don't run together (now a list).
Simon Howkins <simonh@symbian.org>
parents: 57
diff changeset
   104
* $cookedData{$package}->{percentChurn}% churn
57
18edc8e9ec9e Added detection of packages that are new, or have changed from SFL -> EPL.
Simon Howkins <simonh@symbian.org>
parents: 56
diff changeset
   105
$cookedData{$package}->{exception}
82
bbe9783cf993 Updated wiki markup output so that lines don't run together (now a list).
Simon Howkins <simonh@symbian.org>
parents: 57
diff changeset
   106
# Cause1
bbe9783cf993 Updated wiki markup output so that lines don't run together (now a list).
Simon Howkins <simonh@symbian.org>
parents: 57
diff changeset
   107
# etc
49
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   108
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   109
EOT
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   110
}
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   111
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
if (!keys %cookedData)
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   113
{
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   114
	print "'''No packages were identified with large changes.'''";
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   115
}
a5ee079f00dd Tool to help automate the "Mercurial Comparison" part of the Release Notes
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   116