Enable new attribute 'baseline' for new 'baselines' table
authorDario Sestito <darios@symbian.org>
Tue, 13 Jul 2010 18:20:49 +0100
changeset 1176 5fcaa694186a
parent 1175 b1b8e71b0c52
child 1177 10860abeede6
Enable new attribute 'baseline' for new 'baselines' table
common/tools/bitops.pl
--- a/common/tools/bitops.pl	Tue Jul 13 16:47:02 2010 +0100
+++ b/common/tools/bitops.pl	Tue Jul 13 18:20:49 2010 +0100
@@ -63,6 +63,7 @@
   - failure (CATEGORY,COUNT)
   - report (NAME,URL,TYPE)
   - content (NAME,URL,REVISION)
+  - baseline (TYPE,PATH)
   - label (VALUE)
 _EOH
 	exit(0);
@@ -75,6 +76,7 @@
 my $failures = [];
 my $reports = [];
 my $content = [];
+my $baselines = [];
 my $labels = [];
 my $testing_entry = {};
 
@@ -206,6 +208,28 @@
           return 1;
         }
       }
+      elsif ($attr =~ /^(baseline)$/i)
+      {
+        $attr = lc($attr);
+        if ($value =~ /([^,]*),([^,]*)/)
+        {
+          my $type = $1;
+          my $path = $2;
+          
+          if (!$type || !$path)
+          {
+            print "ERROR: Type or path empty: \"$value\"\n";
+            return 1;
+          }
+          print " found ($type,$path) for table 'baselines'\n" if ($verbose);
+          push(@{$baselines}, {type=>$type, path=>$path});
+        }
+        else
+        {
+          print "ERROR: Could not understand value of baseline: \"$value\"\n";
+          return 1;
+        }
+      }
       elsif ($attr =~ /^(label)$/i)
       {
         print " found ($attr,$value) for table 'labels'\n" if ($verbose);
@@ -330,6 +354,22 @@
 		    or print "WARNING: Couldn't execute insert into content ($name,$url,$revision): " . $db->errstr() . "\n" if (!$dryrun);
     }
   }
+  if (@{$baselines})
+  {
+    print " prepare_cached 'insert into baselines (build_id,type,path) values ($newbuildid,?,?)'\n" if ($verbose);
+    my $query = $db->prepare_cached("insert into baselines (build_id,type,path) values ($newbuildid,?,?)")
+      or die("Couldn't prepare query insert into baselines: " . $db->errstr()) if (!$dryrun);
+      
+    for my $entry (@{$baselines})
+    {
+      my $type = $entry->{type};
+      my $path = $entry->{path};
+    
+      print " execute '$type, $path'\n" if ($verbose);  
+      $query->execute($type, $path)
+		    or print "WARNING: Couldn't execute insert into baselines ($type,$path): " . $db->errstr() . "\n" if (!$dryrun);
+    }
+  }
   if (@{$labels})
   {
     print " prepare_cached 'insert into labels (build_id,label) values ($newbuildid,?)'\n" if ($verbose);
@@ -468,6 +508,30 @@
 		    or print "WARNING: Couldn't execute insert into content ($name,$url,$revision): " . $db->errstr() . "\n" if (!$dryrun);
     }
   }
+  if (@{$baselines})
+  {
+    print " prepare 'delete from baselines where build_id=$id'\n" if ($verbose);
+    my $delete_query = $db->prepare("delete from baselines where build_id=$id")
+      or die("Couldn't prepare query delete from baselines: " . $db->errstr()) if (!$dryrun);
+    
+    print " execute ''\n" if ($verbose);  
+    $delete_query->execute()
+		    or print "WARNING: Couldn't execute delete from baselines: " . $db->errstr() . "\n" if (!$dryrun);
+    
+    print " prepare 'insert into baselines (build_id,type,path) values ($id,?,?)'\n" if ($verbose);
+    my $query = $db->prepare_cached("insert into baselines (build_id,type,path) values ($id,?,?)")
+      or die("Couldn't prepare query insert into baselines: " . $db->errstr()) if (!$dryrun);
+      
+    for my $entry (@{$baselines})
+    {
+      my $type = $entry->{type};
+      my $path = $entry->{path};
+    
+      print " execute '$type,$path'\n" if ($verbose);  
+      $query->execute($type, $path)
+		    or print "WARNING: Couldn't execute insert into baselines ($type,$path): " . $db->errstr() . "\n" if (!$dryrun);
+    }
+  }
   if (@{$labels})
   {
     print " prepare 'delete from labels where build_id=$id'\n" if ($verbose);