williamr/summarise_hg_status.pl
changeset 18 4ed8ba809509
child 20 54785ea4cd2e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/williamr/summarise_hg_status.pl	Fri Jul 17 15:16:08 2009 +0100
@@ -0,0 +1,124 @@
+#! perl
+
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+# 
+# Contributors:
+#
+# Description:
+# Summarise the "clone_all_packages.pl -exec -- hg status --rev a --rev b" output
+
+use strict;
+
+my %listings;
+my $current_repo = "";
+my @filelist = ();
+
+sub record_file($$)
+  {
+  my ($file, $change) = @_;
+  
+  next if ($file eq ".hgtags");
+  push @filelist, "$file$change";
+  return;
+  }
+
+sub finished_repo()
+  {
+  if ($current_repo ne "" && scalar @filelist > 0)
+    {
+    $current_repo =~ s/^.*CL\/sf/sf/; # remove leading MCL or FCL stuff
+    @{$listings{$current_repo}} = sort @filelist;
+    # printf STDERR "* %s %d\n", $current_repo, scalar @filelist;
+    }
+  @filelist = ();
+  $current_repo = "";
+  }
+  
+my $line;
+while ($line = <>)
+  {
+  # Processing sfl/MCL/sf/app/imgvieweruis...
+  if ($line =~ /^Processing (.*)\.\.\./)
+    {
+    finished_repo();
+    $current_repo = $1;
+    next;
+    }
+  # abort: unknown revision 'PDK_2.0.c'!
+  if ($line =~ /^abort/)
+    {
+    # ignore the current repo, as it probably didn't have the right tag
+    $current_repo = "";
+    next;
+    }
+  if ($line =~ /^([MARC]) (\S.*\S)\s*$/)
+    {
+    my $change = $1;
+    my $file = $2;
+    record_file($file, $change);
+    next;
+    }
+  }
+
+finished_repo();
+
+print "Package\tChange\tComponent\tFilename\tCount\n";
+foreach my $repo (sort keys %listings)
+  {
+  my @filelist = @{$listings{$repo}};
+  
+  my $last_component = "";
+  my @component_files = ();
+  my @clean_files = ();
+  my $clean_count = 0;
+  my $component = "";
+  
+  foreach my $item (@filelist, ":boo:/:hoo:/:for:/:you:M")
+    {
+    my $change = substr($item,-1);
+    my $file = substr($item,0,-1);
+    my @names = split /\\/, $file;
+    $component = "";
+    if (scalar @names > 2)
+      {
+      my $collection = shift @names;
+      $component = shift @names;
+      $component = $collection . "/" . $component;
+      }
+    $file = join("/", @names);
+    
+    if ($component ne $last_component)
+      {
+      if (scalar @component_files > 0)
+        {
+        # previous component contained some A, M or R files
+        print @component_files;
+        } 
+      if ($clean_count > 0)
+        {
+        print "$repo\tsame\t$last_component\t...\t$clean_count\n";
+        }
+      # reset, ready for next component;
+      $last_component = $component;
+      $clean_count = 0;
+      @component_files = ();
+      @clean_files = ();
+      }
+    if ($change eq "C")
+      {
+      $clean_count += 1;
+      push @clean_files, "$repo\tsame\t$component\t$file\t1\n";
+      }
+    else
+      {
+      push @component_files, "$repo\t$change\t$component\t$file\t1\n";
+      }
+    } 
+  }
\ No newline at end of file