r9004 - in /scripts/qa: DebianQA/Svn.pm fetchdata

tincho-guest at users.alioth.debian.org tincho-guest at users.alioth.debian.org
Wed Nov 7 22:52:26 UTC 2007


Author: tincho-guest
Date: Wed Nov  7 22:52:26 2007
New Revision: 9004

URL: http://svn.debian.org/wsvn/?sc=1&rev=9004
Log:
- fetchdata:
  * correctly convert package names to directories and viceversa.
  * make the post-commit mode more meaningful, calling download_watch with the
    list of changed directories.
  * a little debugging messages.
- Svn:
  * Fixed cache stamp handling (this never worked so far)
  * Discovered a bug in svn-client that prevents log from taking so much arguments, changed a lot the routine. Now asks for a log for each directory, and the code is much cleaner.


Modified:
    scripts/qa/DebianQA/Svn.pm
    scripts/qa/fetchdata

Modified: scripts/qa/DebianQA/Svn.pm
URL: http://svn.debian.org/wsvn/scripts/qa/DebianQA/Svn.pm?rev=9004&op=diff
==============================================================================
--- scripts/qa/DebianQA/Svn.pm (original)
+++ scripts/qa/DebianQA/Svn.pm Wed Nov  7 22:52:26 2007
@@ -52,11 +52,11 @@
         my %dirlist = %{$svn->ls($svnpath, 'HEAD', 0)};
         @dirlist = grep({ $dirlist{$_}->kind() == $SVN::Node::dir }
             keys(%dirlist));
-        debug(scalar @dirlist, " directories to process");
-    }
-    my(@changed, %svn);
+        info(scalar @dirlist, " directories to process");
+    }
+    my(%changed, %svn);
     if($force) {
-        @changed = @dirlist;
+        %changed = map({ $_ => 1 } @dirlist);
     } else {
         my $cdata = read_cache("svn", "", 0);
         if(find_stamp($cdata, "") == $revision
@@ -68,32 +68,25 @@
         my %cache_vers = map({ $_ => find_stamp($cdata, $_) }
             grep({ $cdata->{$_} } @dirlist));
         # Never updated
-        @changed = grep( { not $cache_vers{$_} } @dirlist);
+        %changed = map({ $_ => 1 } grep( { not $cache_vers{$_} } @dirlist));
 
         # Now search in the SVN log to see if there's any interesting change
         # Remove from list already updated parts of the cache
-        my @to_check = grep( {
-                $cache_vers{$_} and $cache_vers{$_} < $revision } @dirlist);
-        if(@to_check) {
-            my @paths = map({ "$svnpath/$_" } @to_check);
-            my $min_rev = (sort(map({ $cache_vers{$_} } @to_check)))[0];
-
-            my %changed = ();
-            $svn->log(\@paths, $min_rev, "HEAD", 1, 1, sub {
-                    foreach(keys %{$_[0]}) {
-                        last if($_[1] < $cache_vers{$1});
-                        next unless(m{/([^/]+)/debian/(changelog|watch)$});
-                        $changed{$1} = 1;
+        foreach my $dir (grep({ $cache_vers{$_}
+                    and $cache_vers{$_} < $revision } @dirlist)) {
+            $svn->log([ "$svnpath/$dir" ], $cache_vers{$dir}, "HEAD", 1, 1,
+                sub {
+                    foreach (keys %{$_[0]}) {
+                        $changed{$dir} = 1 if(m{/debian/(changelog|watch)$});
                     }
                 });
-            push @changed, keys %changed;
         }
         # Copy the not-changed dirs that we want to have the stamp bumped
-        my %changed = map({ $_ => 1} @changed);
         foreach(grep({ ! $changed{$_} } @dirlist)) {
             $svn{$_} = $cdata->{$_} if($cdata->{$_});
         }
     }
+    my @changed = keys %changed;
     foreach my $dir (@changed) {
         $svn{$dir} = {};
         info("Retrieving changelog for $dir");

Modified: scripts/qa/fetchdata
URL: http://svn.debian.org/wsvn/scripts/qa/fetchdata?rev=9004&op=diff
==============================================================================
--- scripts/qa/fetchdata (original)
+++ scripts/qa/fetchdata Wed Nov  7 22:52:26 2007
@@ -33,20 +33,34 @@
 
 die "Invalid module $only" if($only and $only !~ /^(svn|watch|bts|archive)$/);
 if($svn_rev) {
+    info("Enabling post-commit mode");
     $only = "svn";
     $opts->{force} = 0;
 }
 my @dirs = @ARGV;
+my @pkgs;
 
-# We need this first
-svn_download($opts->{force}, $svn_rev, @dirs) if(!$only or $only eq "svn");
-
-# Need to convert?
-if(! $list_is_packages) {
-    foreach my $dir (@dirs) {
-        $dir = svndir2pkgname($dir) || $dir; # Fallback
+if($list_is_packages) {
+    @pkgs = @dirs;
+    foreach(0..$#pkgs) {
+        $dirs[$_] = pkgsname2svndir($pkgs[$_]) || $pkgs[$_]; # Fallback
+    }
+} else {
+    foreach(0..$#dirs) {
+        $pkgs[$_] = svndir2pkgname($dirs[$_]) || $dirs[$_]; # Fallback
     }
 }
+# We need this first
+my @changed_pkgs = svn_download($opts->{force}, $svn_rev, @dirs) if(
+    !$only or $only eq "svn");
+
+# returns dirs, not packages
+foreach(0..$#changed_pkgs) {
+    $changed_pkgs[$_] = svndir2pkgname($changed_pkgs[$_]) || $changed_pkgs[$_];
+}
+info(scalar @changed_pkgs, " changed packages in svn");
+debug("Changed packages in svn: ", join(", ", @changed_pkgs));
+
 if($parallel) {
     local $SIG{CHLD} = "IGNORE";
     my @pids;
@@ -61,18 +75,27 @@
     if(@pids == 2) {
         deb_download($opts->{force}) if(!$only or $only eq "archive"); exit 0;
     } elsif(@pids == 1) {
-        bts_download($opts->{force}, @dirs) if(!$only or $only eq "bts");
+        bts_download($opts->{force}, @pkgs) if(!$only or $only eq "bts");
         exit 0;
     } elsif(@pids == 0) {
-        watch_download($opts->{force}, @dirs) if(!$only or $only eq "watch");
+        if($svn_rev and @changed_pkgs) { # post-commit mode
+            watch_download($opts->{force}, @changed_pkgs);
+        } else {
+            watch_download($opts->{force}, @pkgs) if(!$only
+                    or $only eq "watch");
+        }
         exit 0;
     } else {
         waitpid($_, 0) foreach(@pids);
     }
 } else {
     deb_download($opts->{force}) if(!$only or $only eq "archive");
-    bts_download($opts->{force}, @dirs) if(!$only or $only eq "bts");
-    watch_download($opts->{force}, @dirs) if(!$only or $only eq "watch");
+    bts_download($opts->{force}, @pkgs) if(!$only or $only eq "bts");
+    if($svn_rev and @changed_pkgs) { # post-commit mode
+        watch_download($opts->{force}, @changed_pkgs);
+    } else {
+        watch_download($opts->{force}, @pkgs) if(!$only or $only eq "watch");
+    }
 }
 
 sub help {
@@ -91,8 +114,8 @@
  --packages         Treat the parameters as source package names, instead of
                     directories.
  --svn-revision,
-  -r REV            Current revision for scanning the Subversion repository.
-                    Implies --only svn --no-force (post-commit mode).
+  -r REV            Current revision for scanning the Subversion repository,
+                    only scans svn and watch files changed (post-commit mode).
  --parallel, -j     Process in parallel (it will fork three processes).
  --only MODULE      Only run update for MODULE (svn|archive|watch|bts).
 




More information about the Pkg-perl-cvs-commits mailing list