# HG changeset patch
# User ThomasE
# Date 1245418705 -3600
# Node ID 32693583e769cfde67ac95c422c28da3100a0147
# Parent 25e06db2f72bf47a773f0e3632f2375697057085
Added Hg local cache management feature.
diff -r 25e06db2f72b -r 32693583e769 common/build.xml
--- a/common/build.xml Thu Jun 18 14:32:22 2009 +0100
+++ b/common/build.xml Fri Jun 19 14:38:25 2009 +0100
@@ -24,13 +24,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -40,7 +51,7 @@
-
+
[SF-PREP]
@@ -48,7 +59,7 @@
[SF-BUILD-ALL]
-
+
[SF-BUILD-AND-PACK]
@@ -64,6 +75,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -72,7 +97,7 @@
outputFile="${sf.common.config.dir}/generated/source-spec.ant.xml">
ant: antProperties()
- data: csv(${sf.project.location}/${sf.spec.sourcesync.sourcespecfile}, {separator:','})
+ data: csv(${sf.spec.sourcesync.sourcespecdir}/${sf.spec.sourcesync.sourcespecfile}, {separator:','})
@@ -435,7 +460,7 @@
outputFile="${sf.common.config.dir}/generated/tag-hg-code.ant.xml">
ant: antProperties()
- data: csv(${sf.project.location}/${sf.spec.sourcesync.sourcespecfile}, {separator:','})
+ data: csv(${sf.spec.sourcesync.sourcespecdir}/${sf.spec.sourcesync.sourcespecfile}, {separator:','})
@@ -458,7 +483,7 @@
-
+
@@ -641,7 +666,7 @@
-
+
diff -r 25e06db2f72b -r 32693583e769 common/tools/cachefiles.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/cachefiles.pl Fri Jun 19 14:38:25 2009 +0100
@@ -0,0 +1,128 @@
+#!/usr/bin/perl
+
+
+use strict;
+
+#my $cache = "d:/HG_cache/";
+#my $master = "//v800008/Builds01/";
+my $cache = shift @ARGV;
+my $csv = shift @ARGV;
+my $generated = shift @ARGV;
+my @recover;
+my @nospace;
+my $exitcode = 0;
+
+if(defined $cache && defined $generated && defined $csv)
+{
+ print "Cache:$cache\nIn:$csv\nOut:$generated\n";
+
+ # Format the cache directory path
+ if ( $cache !~ /(.*)[\\\/]$/ )
+ {
+ $cache .= "/";
+ }
+
+ open(IN, "<$csv") or die "Couldn't open $csv for reading";
+ open(OUT,">$generated") or die "Couldn't open $generated for writing";
+ my $header = ;
+ print OUT $header;
+ while( my $line = )
+ {
+ my @args = split(',',$line);
+ my $repo = shift @args;
+ my $master = "";
+ if ( $repo =~ m/^(.*\/)((oss|rnd|sfl)\/.*\/)$/i )
+ {
+ $master = $1;
+ $repo = $2;
+ }
+ if(-d $master.$repo.".hg")
+ {
+ # print "Found:\t".$master.$repo.".hg\n";
+ my $cmd;
+ if(-d $cache.$repo.".hg") # update
+ {
+ $cmd = "hg pull -R $cache$repo $master$repo";
+ }
+ else #clone
+ {
+ #taken from the normal clone script...
+ my @dirs = split ('\/', $cache.$repo);
+ my $destdir = pop @dirs;
+ my $path = "";
+ foreach my $dir (@dirs)
+ {
+ $path = ($path eq "") ? $dir : "$path/$dir";
+ if (!-d $path)
+ {
+ mkdir $path;
+ }
+ }
+
+ $cmd = "hg clone -U $master$repo $cache$repo";
+ }
+ if(cache($cmd))
+ {
+ print OUT $cache.$repo.",".join(',', @args);
+ }
+ else
+ {
+ print OUT $master.$repo.",".join(',', @args);
+ $exitcode = 1;
+ }
+ }
+ else
+ {
+ print "Error: cannot find ".$master.$repo.".hg\n";
+ $exitcode = 1;
+ }
+ }
+
+ close OUT;
+ close IN;
+}
+else
+{
+ print "Usage: ";
+ $exitcode = 1;
+}
+
+foreach my $line (@recover)
+{
+ print "WARNING: HG Recover: $line\n";
+}
+foreach my $line (@nospace)
+{
+ print "WARNING: No Space: $line\n";
+}
+
+exit $exitcode;
+
+sub cache($cmd)
+{
+ my $cmd = shift;
+ print "$cmd\n";
+
+ open(CMD, "$cmd 2>&1 |") or die "Couldn't execute $cmd";
+ while(my $line = )
+ {
+# print $line;
+ # parse the output for failures. On fail return 0;
+ if($line =~ m/abort/i)
+ {
+ print $line;
+ if($line =~ m/hg\s+recover/i)
+ {
+ push(@recover, $cmd);
+ }
+ elsif($line =~ m/No\s+space/i)
+ {
+ push(@nospace, $cmd);
+ }
+ close CMD;
+ return 0;
+ }
+ }
+ close CMD;
+ return 1;
+}
\ No newline at end of file