releaseAutomation/mercurialComparison.pl
changeset 56 67168a24b405
parent 50 a5ee079f00dd
child 57 9b6317ec9e32
equal deleted inserted replaced
55:7b39c2ae2526 56:67168a24b405
    23 my $previousPdkLabel = shift or die  "Second argument must be hg label to compare against\n";
    23 my $previousPdkLabel = shift or die  "Second argument must be hg label to compare against\n";
    24 my $detailsTsvFilename = shift or die "Third argument must be filename to write detailed TSV data into\n";
    24 my $detailsTsvFilename = shift or die "Third argument must be filename to write detailed TSV data into\n";
    25 defined shift and die "No more than three arguments please\n";
    25 defined shift and die "No more than three arguments please\n";
    26 
    26 
    27 # Use external scripts to get the raw data and produce the CSV summary (to go into Excel, etc)
    27 # Use external scripts to get the raw data and produce the CSV summary (to go into Excel, etc)
    28 system("perl $FindBin::Bin\\..\\clone_packages\\clone_all_packages.pl -packagelist $bomInfoFile -exec -- hg status -C --rev $previousPdkLabel 2>&1 | perl $FindBin::Bin\\..\\williamr\\summarise_hg_status.pl 2> nul: > $detailsTsvFilename");
    28 #system("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> nul: > $detailsTsvFilename");
    29 
    29 
    30 # The redirection above means that we discard STDERR from summarise_hg_status,
    30 # The redirection above means that we discard STDERR from summarise_hg_status,
    31 # which lists packages for which it was unable to generate any data
    31 # which lists packages for which it was unable to generate any data
    32 # 
    32 # 
    33 # It's discarded because that happens either because it's a new package or has
    33 # It's discarded because that happens either because it's a new package or has
    58 
    58 
    59 # Pivot
    59 # Pivot
    60 my %cookedData;
    60 my %cookedData;
    61 foreach my $datum (@rawData)
    61 foreach my $datum (@rawData)
    62 {
    62 {
    63 	next if $datum->{Change} =~ m{^(same|M)$};
    63 	# Accumulate the total number of files in the old revision of the pkg
    64 	$cookedData{$datum->{Package}} += $datum->{Count};
    64 	$cookedData{$datum->{Package}}->{totalFiles} += $datum->{Count} unless $datum->{Change} eq "A";
       
    65 	$cookedData{$datum->{Package}}->{same} += $datum->{Count} if $datum->{Change} eq "same";
       
    66 	$cookedData{$datum->{Package}}->{addRemove} += $datum->{Count} if $datum->{Change} =~ m{^[AR]$};
    65 }
    67 }
    66 
    68 
    67 # Cut-off for "interesting" packages
    69 # Cut-off for "interesting" packages
    68 foreach my $package (keys %cookedData)
    70 foreach my $package (keys %cookedData)
    69 {
    71 {
    70 	delete $cookedData{$package} unless $cookedData{$package} >= 350;
    72 	# Ensure items are defined
       
    73 	$cookedData{$package}->{totalFiles} |= 1;
       
    74 	$cookedData{$package}->{same} |= 0;
       
    75 	$cookedData{$package}->{addRemove} |= 0;
       
    76 	$cookedData{$package}->{percentChurn} = 100 * (1 - ($cookedData{$package}->{same} / $cookedData{$package}->{totalFiles}));
       
    77 	
       
    78 	# More than N files added + removed
       
    79 	next if $cookedData{$package}->{addRemove} >= 400;
       
    80 	# More than M% churn
       
    81 	next if $cookedData{$package}->{percentChurn} > 30;
       
    82 	# Nothing interesting about this package
       
    83 	delete $cookedData{$package};
    71 }
    84 }
    72 
    85 
    73 # Output
    86 # Output
    74 print <<"EOT";
    87 print <<"EOT";
    75 == Mercurial Comparison with $previousPdkLabel ==
    88 == Mercurial Comparison with $previousPdkLabel ==
    85 foreach my $package (sort keys %cookedData)
    98 foreach my $package (sort keys %cookedData)
    86 {
    99 {
    87 	print <<"EOT";
   100 	print <<"EOT";
    88 === $package ===
   101 === $package ===
    89 
   102 
    90 $cookedData{$package} files added/removed
   103 $cookedData{$package}->{addRemove} files added/removed
       
   104 $cookedData{$package}->{percentChurn}% churn
    91 
   105 
    92 * Cause1
   106 * Cause1
    93 * etc
   107 * etc
    94 
   108 
    95 EOT
   109 EOT