williamr/summarise_hg_status.pl
changeset 18 4ed8ba809509
child 20 54785ea4cd2e
equal deleted inserted replaced
17:35c6c3f66bc4 18:4ed8ba809509
       
     1 #! perl
       
     2 
       
     3 # Copyright (c) 2009 Symbian Foundation Ltd
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Symbian Foundation Ltd - initial contribution.
       
    11 # 
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # Summarise the "clone_all_packages.pl -exec -- hg status --rev a --rev b" output
       
    16 
       
    17 use strict;
       
    18 
       
    19 my %listings;
       
    20 my $current_repo = "";
       
    21 my @filelist = ();
       
    22 
       
    23 sub record_file($$)
       
    24   {
       
    25   my ($file, $change) = @_;
       
    26   
       
    27   next if ($file eq ".hgtags");
       
    28   push @filelist, "$file$change";
       
    29   return;
       
    30   }
       
    31 
       
    32 sub finished_repo()
       
    33   {
       
    34   if ($current_repo ne "" && scalar @filelist > 0)
       
    35     {
       
    36     $current_repo =~ s/^.*CL\/sf/sf/; # remove leading MCL or FCL stuff
       
    37     @{$listings{$current_repo}} = sort @filelist;
       
    38     # printf STDERR "* %s %d\n", $current_repo, scalar @filelist;
       
    39     }
       
    40   @filelist = ();
       
    41   $current_repo = "";
       
    42   }
       
    43   
       
    44 my $line;
       
    45 while ($line = <>)
       
    46   {
       
    47   # Processing sfl/MCL/sf/app/imgvieweruis...
       
    48   if ($line =~ /^Processing (.*)\.\.\./)
       
    49     {
       
    50     finished_repo();
       
    51     $current_repo = $1;
       
    52     next;
       
    53     }
       
    54   # abort: unknown revision 'PDK_2.0.c'!
       
    55   if ($line =~ /^abort/)
       
    56     {
       
    57     # ignore the current repo, as it probably didn't have the right tag
       
    58     $current_repo = "";
       
    59     next;
       
    60     }
       
    61   if ($line =~ /^([MARC]) (\S.*\S)\s*$/)
       
    62     {
       
    63     my $change = $1;
       
    64     my $file = $2;
       
    65     record_file($file, $change);
       
    66     next;
       
    67     }
       
    68   }
       
    69 
       
    70 finished_repo();
       
    71 
       
    72 print "Package\tChange\tComponent\tFilename\tCount\n";
       
    73 foreach my $repo (sort keys %listings)
       
    74   {
       
    75   my @filelist = @{$listings{$repo}};
       
    76   
       
    77   my $last_component = "";
       
    78   my @component_files = ();
       
    79   my @clean_files = ();
       
    80   my $clean_count = 0;
       
    81   my $component = "";
       
    82   
       
    83   foreach my $item (@filelist, ":boo:/:hoo:/:for:/:you:M")
       
    84     {
       
    85     my $change = substr($item,-1);
       
    86     my $file = substr($item,0,-1);
       
    87     my @names = split /\\/, $file;
       
    88     $component = "";
       
    89     if (scalar @names > 2)
       
    90       {
       
    91       my $collection = shift @names;
       
    92       $component = shift @names;
       
    93       $component = $collection . "/" . $component;
       
    94       }
       
    95     $file = join("/", @names);
       
    96     
       
    97     if ($component ne $last_component)
       
    98       {
       
    99       if (scalar @component_files > 0)
       
   100         {
       
   101         # previous component contained some A, M or R files
       
   102         print @component_files;
       
   103         } 
       
   104       if ($clean_count > 0)
       
   105         {
       
   106         print "$repo\tsame\t$last_component\t...\t$clean_count\n";
       
   107         }
       
   108       # reset, ready for next component;
       
   109       $last_component = $component;
       
   110       $clean_count = 0;
       
   111       @component_files = ();
       
   112       @clean_files = ();
       
   113       }
       
   114     if ($change eq "C")
       
   115       {
       
   116       $clean_count += 1;
       
   117       push @clean_files, "$repo\tsame\t$component\t$file\t1\n";
       
   118       }
       
   119     else
       
   120       {
       
   121       push @component_files, "$repo\t$change\t$component\t$file\t1\n";
       
   122       }
       
   123     } 
       
   124   }