[Collab-qa-commits] r397 - svnbuildstat/script

goneri-guest at alioth.debian.org goneri-guest at alioth.debian.org
Sat Sep 1 12:10:41 UTC 2007


Author: goneri-guest
Date: 2007-09-01 12:10:41 +0000 (Sat, 01 Sep 2007)
New Revision: 397

Modified:
   svnbuildstat/script/svnbuildstat_update-db.pl
Log:
a lot of stuff...


Modified: svnbuildstat/script/svnbuildstat_update-db.pl
===================================================================
--- svnbuildstat/script/svnbuildstat_update-db.pl	2007-09-01 12:09:43 UTC (rev 396)
+++ svnbuildstat/script/svnbuildstat_update-db.pl	2007-09-01 12:10:41 UTC (rev 397)
@@ -6,7 +6,7 @@
 use LWP::UserAgent;
 use Data::Dumper;
 use File::Basename;
-use Time::Local;
+use Time::Local 'timelocal_nocheck';
 
 use threads;
 use threads::shared;
@@ -150,9 +150,59 @@
   return {tarballuri => $tarballuri, isuptodate => $isuptodate, upstreamrelease => $upstreamrelease, iswatchfilebroken => $iswatchfilebroken};
 }
 
+sub updateChangelog {
+  my $package = shift;
 
+  print "UPDATE CHANGELOG\n";
+
+  my $last_rev;
+  my $vcschangelog_rs = $schema->resultset('Vcschangelog')->search({
+      package_id => $$package->id,
+    }, {order_by => "rev DESC"});
+  $last_rev = $vcschangelog_rs->first->rev if ($vcschangelog_rs->first);
+  if (!$last_rev) {
+    my $build_rs = $schema->resultset('Build')->search({
+	package_id => $$package->id,
+      }, {order_by => "rev"});
+    $last_rev = $build_rs->first->rev if ($build_rs->first);
+  }
+
+  return unless $last_rev;
+  print "LAST REV:". $last_rev."\n";
+
+  my $cmd = "LC_ALL=C svn log -r ".$last_rev.":".$$package->rev." ".$$package->uri;
+  my $begin;
+  my $entry;
+  foreach (`$cmd`) {
+    if (/^------------------------------------------------------------------------/) {
+      $begin = 1;
+      $entry->update if $entry;
+      $entry = undef;
+    } elsif ($begin) {
+      if (/r(\d+)\s\|\s(\S+)\s\|\s(20\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d)/) {
+	my $rev = $1;
+	my $login = $2;
+	my $date = $3;
+	my $aliothlogin = $schema->resultset('Aliothlogin')->find_or_create({name=>$login});
+	$entry = $schema->resultset('Vcschangelog')->create({
+	    aliothlogin_id =>$aliothlogin->id,
+	    package_id => $$package->id,
+	    date => $date,
+	    rev => $rev,
+	  });
+
+	$begin = 0;
+      }
+
+    } elsif ($entry) {
+      $entry->log($entry->log.$_);
+    }
+
+  }
+  $entry->update if $entry;
+}
+
 sub importPkg {
-  print "ImportPkg\n";
   my( $repository, $uri, $tarballonrepository) = @_;
 
   my @maintainer;
@@ -206,18 +256,34 @@
 
   }
   my $package = $schema->resultset('Package')->find_or_create({name => $packagesrc});
-  return unless $rev > $$package->rev; # do not continue unless needed
+
+  # if the source is not in the pool I can suppose the tarball was missing for the last
+  # check and so I need to check periodicly to see if the status has changed
+  if ($rev > $package->rev) {
+    if (!$package->issrcinmypool) {
+      my ($year, $mon, $day, $hour, $min, $sec) = ($package->lastcheck =~ /(\d{4})-(\d+)-(\d+)\ (\d+):(\d+):(\d+)/);
+      my $lastcheck = timelocal_nocheck($sec, $min, $hour, $day, $mon, $year);
+      if ($lastcheck > time - 3600*24) {
+	print "No need to refresh ".$package->name."\n";
+	return;
+      }
+    }
+    return;
+  }
+  print "GO ".$package->name."\n";
+
   $package->issrcinmypool (0);
 
+  my $hasunreleasedchangelogentry;
   my @changelog = `svn cat $uri/debian/changelog`;
   if (@changelog) {
 
-
     foreach (@changelog) {
       if (/^\S/ && $currentchangelogentry) {
 	# I ignore svn-bp empty template entry
 	if ($currentchangelogentry =~ /^.*\n\s\s\*\sNOT RELEASED YET\n\n\s--.*/m) {
 	  $currentchangelogentry = '';
+	  $hasunreleasedchangelogentry = 1;
 	} else {
 	  last; 
 	}
@@ -227,12 +293,10 @@
    
     if ($currentchangelogentry =~ /^.*\ \((.*)\)/) {
       $svndebrelease = $1; 
-      print "OK\n";
-    } else {
-      print "PAS OK\n";
     }
     # looks for bug closed in the changelog entry
     # the regex come from the BTS documentation
+    # TODO dpkg-parsechangelog is probably more suitable for the job :D
     foreach ($currentchangelogentry =~ /closes:\s*(?:bug)?\#\s*\d+(?:,\s*(?:bug)?\#\s*\d+)*/ig) {
       s/([A-Za-z]|#|:|\s)//g;
       $currentpendingbug .= $_.',' if $_;
@@ -251,7 +315,7 @@
   if (@todo) {
     $todo .= $_ foreach @todo;
   }
-
+  $package->hasunreleasedchangelogentry($hasunreleasedchangelogentry);
   $package->update_from_related('repository_id',$$repository);
   
   $package->svndebrelease ($svndebrelease);
@@ -264,6 +328,7 @@
   }
 
 
+  updateChangelog(\$package);
   # Search for the tarball
   my $tarball = mkTarballFromPackage(\$package);
   my $uscandata = getUscanData(\$package);
@@ -341,9 +406,10 @@
   if ($$repository->rev eq $rev && $$repository->lastcheck) {
     # If he repository is up to date, a still do a refresh every 48h
     # this because of the tarball check
-    my ($year, $mon, $day, $hour, $min, $sec) = ($$repository->lastcheck =~ /(\d{4})-(\d{2})-(\d{2})\ (\d{1,2}):(\d{2}):(\d{2})/);
-    my $lastbuild = timelocal($sec, $min, $hour, $day, $mon, $year);
-    if ($lastbuild > time - 3600*48) {
+    #
+    my ($year, $mon, $day, $hour, $min, $sec) = ($$repository->lastcheck =~ /(\d{4})-(\d+)-(\d+)\ (\d+):(\d+):(\d+)/);
+    my $lastcheck = timelocal_nocheck($sec, $min, $hour, $day, $mon, $year);
+    if ($lastcheck > time - 3600*48) {
       print "No need to refresh ".$$repository->name."\n";
       return;
     }




More information about the Collab-qa-commits mailing list