add utils to parse output of clone_all_packages.pl and to remove credentials from the local clone
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/clone_packages/parse_clone_all.pl Thu Sep 24 09:33:30 2009 +0100
@@ -0,0 +1,87 @@
+#! 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:
+# Perl script to summarise output from clone_all_package.pl
+
+
+@all = <>;
+
+my $repo;
+my $newrepo = 0;
+my $errors = 0;
+my $summary = 0;
+my $retries = 0;
+foreach my $line (@all)
+{
+ if($summary)
+ {
+ # if we are in the summary section then just echo all lines out
+ # this should be a list of all the packages with errors
+ print "$line\n";
+ }
+ #save package name
+ # e.g new package "Cloning compatanaapps from sfl/MCL/sftools/ana/compatanaapps..."
+ # e.g. existing package "Updating helix from sfl/MCL/sf/mw/helix..."
+ # e.g. with -exec option "Processing sfl/FCL/interim/auxiliary_tools/AgileBrowser."
+ elsif ($line =~ m/Cloning (.*?)from(.*)$/)
+ {
+ $repo = $2;
+ $newrepo = 1;
+ $retries =0;
+ }
+ elsif ($line =~ m/Updating (.*?)from(.*)$/)
+ {
+ $repo = $2;
+ $newrepo = 0;
+ $retries =0;
+ }
+
+ #
+ # Capture number of changes, should be line like one of the following
+ # e.g. "added 4 changesets with 718 changes to 690 files"
+ # e.g. "no changes found"
+ elsif ($line =~ m/added (.*?)changesets with(.*)$/)
+ {
+ print "\n$repo\t added $1 chamgesets";
+ print "\t retries $retries";
+ print "\t** NEW" if ($newrepo);
+ }
+
+ if($line =~ m/abort:/)
+ {
+ $retries++;
+ }
+
+ # Process the summary section
+ # e.g. "------------"
+ # e.g. "Processed 22 packages, of which 0 reported errors"
+ if ($line =~ m/Processed (.*?)packages, of which(.*?)reported errors/)
+ {
+ print "\n-------------------------------\n";
+ print "\n Summary: Processed $1 : Errors $2\n";
+ $errors= $2;
+ $summary = 1;
+ }
+
+}
+if ($errors > 0)
+{
+ print "\nexit with error\n";
+ exit 1;
+}
+else
+{
+ print "\nexit success\n";
+ exit 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/clone_packages/patch_hgrc.py Thu Sep 24 09:33:30 2009 +0100
@@ -0,0 +1,93 @@
+#! /usr/bin/python
+# 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:
+# Python script to manipulate the hgrc files
+
+from ConfigParser import *
+import optparse
+import os
+import sys
+import re
+
+verbose = False;
+credentials= re.compile(r"//.*?@")
+
+def strip_credentials(hgrc):
+ """ Remove the user credentials from the default path in hgrc file"""
+ # e.g.
+ # before http://user:pass@prod.foundationhost.org/sfl/MCL/sf/os/boardsupport/
+ # after http://prod.foundationhost.org/sfl/MCL/sf/os/boardsupport/
+ if hgrc.has_section('paths'):
+ if (verbose): print hgrc.items('paths')
+ defpath = hgrc.get('paths', 'default')
+ newpath = credentials.sub(r"//",defpath)
+ #print "new path ", newpath
+ hgrc.set('paths', 'default',newpath)
+ elif (verbose):
+ if (verbose): print "No [paths] section\n"
+
+def add_hooks(hgrc):
+ if (hgrc.has_section('hooks')):
+ # unpdate
+ if (verbose) : print 'updating existing hooks section'
+ else:
+ if (verbose) : print 'adding hooks section'
+ hgrc.add_section('hooks')
+ # add example (windows only) hook to block local commit to the repo
+ hgrc.set('hooks', 'pretxncommit.abort', 'exit /b 1')
+ hgrc.set('hooks', 'pretxncommit.message', 'ERROR: This is a read only repo')
+
+
+def write_hgrcfile(hgrc,fout):
+ fnewini = file(fout,'w')
+ hgrc.write(fnewini)
+ fnewini.close()
+
+def main():
+ global verbose
+ usage = "usage: %prog [options]"
+ try:
+ parser = optparse.OptionParser(usage)
+ parser.set_defaults(filename=".hg/hgrc")
+ parser.add_option("-f","--file", dest="filename", default=".hg/hgrc",metavar="FILE" , help='file to be patched')
+ parser.add_option("-v", action="store_true",dest="verbose",default=False, help='Verbose trace information')
+ (options, args) = parser.parse_args()
+ except:
+ parser.print_help()
+ sys.exit(1)
+
+ f = os.path.abspath(options.filename)
+ if(options.verbose):
+ verbose = True
+ print f
+ if(os.path.isfile(f)):
+ try:
+ #conff = file(f,'w') #open file f for read/write
+ hgrcfile = RawConfigParser()
+ hgrcfile.read(f)
+ if (verbose):
+ print hgrcfile.sections()
+ except:
+ print 'Something failed opening the configuration file'
+ sys.exit(2)
+ else:
+ print "Configuration file does not exist? ",f
+ sys.exit(2)
+
+ strip_credentials(hgrcfile)
+ add_hooks(hgrcfile)
+ write_hgrcfile(hgrcfile,f)
+
+
+if __name__ == "__main__":
+ main()