]> git.donarmstrong.com Git - debbugs.git/commitdiff
merge changes from archimedes
authorDon Armstrong <don@donarmstrong.com>
Fri, 1 Aug 2008 04:00:01 +0000 (21:00 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 1 Aug 2008 04:00:01 +0000 (21:00 -0700)
Debbugs/Config.pm
Debbugs/Control.pm
Debbugs/Log.pm
Debbugs/Status.pm
Debbugs/User.pm
cgi/pkgreport.cgi
t/06_mail_handling.t
t/07_bugreport.t
t/09_soap.t
t/lib/DebbugsTest.pm

index 34a825791fbbe59f7db8ae24e0fbcd45e28e7c45..39171ac2e00a07ca94987d455adba73fb110a929 100644 (file)
@@ -62,6 +62,7 @@ BEGIN {
                                 qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities),
                                 qw(%gSearchEstraier),
                                 qw(%gDistributionAliases),
+                                qw(%gObsoleteSeverities),
                                 qw(@gPostProcessall @gRemovalDefaultDistributionTags @gRemovalDistributionTags @gRemovalArchitectures),
                                 qw(@gRemovalStrongSeverityDefaultDistributionTags),
                                 qw(@gDefaultArchitectures),
@@ -604,6 +605,16 @@ Defaults to the keys of the severity display hashref
 
 set_default(\%config,'severity_list',[keys %{$config{severity_display}}]);
 
+=item obsolete_severities
+
+A hashref of obsolete severities with the replacing severity
+
+Default: {}
+
+=cut
+
+set_default(\%config,'obsolete_severities',{});
+
 =item tags
 
 An arrayref of the tags used
index dd3eb58ff42a0d8b25df1555a5803a47710b05e5..493125102e242d267ab06d1b094e9acbe3f2036e 100644 (file)
@@ -104,9 +104,11 @@ use Debbugs::Mail qw(rfc822_date);
 
 use POSIX qw(strftime);
 
+use Carp;
+
 # These are a set of options which are common to all of these functions
 
-my %common_options = (debug       => {type => SCALARREF,
+my %common_options = (debug       => {type => SCALARREF|HANDLE,
                                      optional => 1,
                                     },
                      transcript  => {type => SCALARREF|HANDLE,
@@ -276,16 +278,17 @@ sub bug_archive {
                                )
                              )
               if not exists $param{append_log} or $param{append_log};
-         my @files_to_remove = map {s#db-h/$dir/##; $_} glob("db-h/$dir/$bug.*");
+         my @files_to_remove = map {s#$config{spool_dir}/db-h/$dir/##; $_} glob("$config{spool_dir}/db-h/$dir/$bug.*");
          if ($config{save_old_bugs}) {
-              mkpath("archive/$dir");
+              mkpath("$config{spool_dir}/archive/$dir");
               foreach my $file (@files_to_remove) {
-                   link( "db-h/$dir/$file", "archive/$dir/$file" ) || copy( "db-h/$dir/$file", "archive/$dir/$file" );
+                   link( "$config{spool_dir}/db-h/$dir/$file", "$config{spool_dir}/archive/$dir/$file" ) or
+                        copy( "$config{spool_dir}/db-h/$dir/$file", "$config{spool_dir}/archive/$dir/$file" );
               }
 
               print {$transcript} "archived $bug to archive/$dir (from $param{bug})\n";
          }
-         unlink(map {"db-h/$dir/$_"} @files_to_remove);
+         unlink(map {"$config{spool_dir}/db-h/$dir/$_"} @files_to_remove);
          print {$transcript} "deleted $bug (from $param{bug})\n";
      }
      bughook_archive(@bugs);
@@ -370,15 +373,15 @@ sub bug_unarchive {
      for my $bug (@bugs) {
          print {$debug} "$param{bug} removing $bug\n";
          my $dir = get_hashname($bug);
-         my @files_to_copy = map {s#archive/$dir/##; $_} glob("archive/$dir/$bug.*");
+         my @files_to_copy = map {s#$config{spool_dir}/archive/$dir/##; $_} glob("$config{spool_dir}/archive/$dir/$bug.*");
          mkpath("archive/$dir");
          foreach my $file (@files_to_copy) {
               # die'ing here sucks
-              link( "archive/$dir/$file", "db-h/$dir/$file" ) or
-                   copy( "archive/$dir/$file", "db-h/$dir/$file" ) or
-                        die "Unable to copy archive/$dir/$file to db-h/$dir/$file";
+              link( "$config{spool_dir}/archive/$dir/$file", "$config{spool_dir}/db-h/$dir/$file" ) or
+                   copy( "$config{spool_dir}/archive/$dir/$file", "$config{spool_dir}/db-h/$dir/$file" ) or
+                        die "Unable to copy $config{spool_dir}/archive/$dir/$file to $config{spool_dir}/db-h/$dir/$file";
          }
-         push @files_to_remove, map {"archive/$dir/$_"} @files_to_copy;
+         push @files_to_remove, map {"$config{spool_dir}/archive/$dir/$_"} @files_to_copy;
          print {$transcript} "Unarchived $config{bug} $bug\n";
      }
      unlink(@files_to_remove) or die "Unable to unlink bugs";
@@ -482,15 +485,14 @@ sub __handle_debug_transcript{
                               spec   => {%common_options},
                               allow_extra => 1,
                              );
-     my $fake_scalar = '';
-     my $debug = globify_scalar(exists $param{debug}?$param{debug}:\$fake_scalar);
-     my $transcript = globify_scalar(exists $param{transcript}?$param{transcript}:\$fake_scalar);
+     my $debug = globify_scalar(exists $param{debug}?$param{debug}:undef);
+     my $transcript = globify_scalar(exists $param{transcript}?$param{transcript}:undef);
      return ($debug,$transcript);
-
 }
 
 sub __return_append_to_log_options{
-     my %param = @_
+     my %param = @_;
+     my $action = $param{action} if exists $param{action};
      if (not exists $param{requester}) {
          $param{requester} = $config{control_internal_requester};
      }
@@ -498,7 +500,6 @@ sub __return_append_to_log_options{
          $param{request_addr} = $config{control_internal_request_addr};
      }
      if (not exists $param{message}) {
-         $action = $param{action} if exists $param{action};
          my $date = rfc822_date();
          $param{message} = fill_in_template(template  => 'mail/fake_control_message',
                                             variables => {request_addr => $param{request_addr},
@@ -508,8 +509,14 @@ sub __return_append_to_log_options{
                                                          },
                                            );
      }
+     if (not defined $action) {
+         carp "Undefined action!";
+         $action = "unknown action";
+     }
      return (action => $action,
-            %param);
+            (map {exists $append_action_options{$_}?($_,$param{$_}):()}
+             keys %param),
+           );
 }
 
 
index 97f0b0014b69b2aa2b212af2c5169d96f3af9a7b..c4d741e6ab46f322a9519075c2d60cbba416de64 100644 (file)
@@ -165,7 +165,7 @@ sub new
         ($param{logfh}) = @_;
     }
     else {
-        %param = validate_with(params => @_,
+        %param = validate_with(params => \@_,
                                spec   => {bug_num => {type => SCALAR,
                                                       optional => 1,
                                                      },
index 72b040f545a2879759d704eaa052227ee4da2c6d..26ffa3c99c729007f4564a7f52613515e8fb12b0 100644 (file)
@@ -178,7 +178,7 @@ sub read_bug{
         $log =~ s/\.summary$/.log/;
         ($location) = $status =~ m/(db-h|db|archive)/;
     }
-    my $status_fh = new IO::File $status, 'r' or
+    my $status_fh = IO::File->new($status, 'r') or
         warn "Unable to open $status for reading: $!" and return undef;
 
     my %data;
@@ -248,7 +248,7 @@ See readbug above for information on what this returns
 
 sub lockreadbug {
     my ($lref, $location) = @_;
-    &filelock("lock/$lref");
+    &filelock("$config{spool_dir}/lock/$lref");
     my $data = read_bug(bug => $lref, location => $location);
     &unfilelock unless defined $data;
     return $data;
@@ -274,7 +274,7 @@ sub lockreadbugmerge {
          return (1,$data);
      }
      unfilelock();
-     filelock('lock/merge');
+     filelock("$config{spool_dir}/lock/merge");
      $data = lockreadbug(@_);
      if (not defined $data) {
          unfilelock();
@@ -1249,7 +1249,7 @@ sub update_realtime {
 
 sub bughook_archive {
        my @refs = @_;
-       &filelock("debbugs.trace.lock");
+       &filelock("$config{spool_dir}/debbugs.trace.lock");
        &appendfile("debbugs.trace","archive ".join(',',@refs)."\n");
        my %bugs = update_realtime("$config{spool_dir}/index.db.realtime",
                                   map{($_,'REMOVE')} @refs);
@@ -1260,7 +1260,7 @@ sub bughook_archive {
 
 sub bughook {
        my ( $type, %bugs_temp ) = @_;
-       &filelock("debbugs.trace.lock");
+       &filelock("$config{spool_dir}/debbugs.trace.lock");
 
        my %bugs;
        for my $bug (keys %bugs_temp) {
index 52116a7242dcda0bff37bfb76de8b65c7e969187..d7fcbe217b6defe4fc1efdc8c0f1207a5c0d58cc 100644 (file)
@@ -142,14 +142,14 @@ sub new {
     bless $self, $class;
 
     $self->{filename} = _file_from_email($self->{email});
-    if (not -r $p) {
-        return bless $user, "Debbugs::User";
+    if (not -r $self->{filename}) {
+        return $self;
     }
-    my $uf = IO::File->new($p,'r')
-        or die "Unable to open file $p for reading: $!";
+    my $uf = IO::File->new($self->{filename},'r')
+        or die "Unable to open file $self->{filename} for reading: $!";
     if ($need_lock) {
         flock($uf, LOCK_EX);
-        $user->{"locked"} = $uf;
+        $self->{"locked"} = $uf;
     }
 
     while(1) {
@@ -220,7 +220,7 @@ sub new {
 
 sub write {
     my $self = shift;
-    my $uf;
+
     my $ut = $self->{"tags"};
     my $p = $self->{"filename"};
 
@@ -320,9 +320,9 @@ sub read_usertags {
 
     carp "read_usertags is deprecated";
     my $user = get_user($email);
-    for my $t (keys %{$user->{"tags"}}) {
-        $ut->{$t} = [] unless defined $ut->{$t};
-        push @{$ut->{$t}}, @{$user->{"tags"}->{$t}};
+    for my $tag (keys %{$user->{"tags"}}) {
+        $usertags->{$tag} = [] unless defined $usertags->{$tag};
+        push @{$usertags->{$tag}}, @{$user->{"tags"}->{$tag}};
     }
     return $usertags;
 }
@@ -341,7 +341,7 @@ sub write_usertags {
 
     carp "write_usertags is deprecated";
     my $user = Debbugs::User->new($email,1); # locked
-    $user->{"tags"} = { %{$ut} };
+    $user->{"tags"} = { %{$usertags} };
     $user->write();
 }
 
index 8736e8c0570a1305c91193d167adf9ba857104d5..3c6afe36178b5d7137150d0fa99f21e24794d1df 100755 (executable)
@@ -25,18 +25,18 @@ use Debbugs::Packages qw(getsrcpkgs getpkgsrc get_versions);
 use Debbugs::Status qw(:status);
 use Debbugs::CGI qw(:all);
 
-use vars qw($gPackagePages $gWebDomain %gSeverityDisplay @gSeverityList);
-
-if (defined $ENV{REQUEST_METHOD} and $ENV{REQUEST_METHOD} eq 'HEAD') {
-    print "Content-Type: text/html; charset=utf-8\n\n";
-    exit 0;
-}
-
-nice(5);
+use Debbugs::Text qw(:templates);
 
 use CGI::Simple;
 my $q = new CGI::Simple;
 
+if ($q->request_method() eq 'HEAD') {
+     print $q->header(-type => "text/html",
+                     -charset => 'utf-8',
+                    );
+     exit 0;
+}
+
 our %param = cgi_parameters(query => $q,
                            single => [qw(ordering archive repeatmerged),
                                       qw(bug-rev pend-rev sev-rev),
@@ -46,6 +46,8 @@ our %param = cgi_parameters(query => $q,
                            default => {ordering => 'normal',
                                        archive  => 0,
                                        repeatmerged => 1,
+                                       include      => [],
+                                       exclude      => [],
                                       },
                           );
 
@@ -69,7 +71,6 @@ elsif (lc($param{archive}) eq 'yes') {
 }
 
 
-my $archive = ($param{'archive'} || "no") eq "yes";
 my $include = $param{'&include'} || $param{'include'} || "";
 my $exclude = $param{'&exclude'} || $param{'exclude'} || "";
 
@@ -165,7 +166,8 @@ our %cats = (
 );
 
 my @select_key = (qw(submitter maint pkg package src usertag),
-                 qw(status tag maintenc owner severity newest)
+                 qw(status tag maintenc owner severity newest),
+                 qw(correspondent),
                 );
 
 if (exists $param{which} and exists $param{data}) {
@@ -213,7 +215,7 @@ if (defined $param{usertag}) {
      }
 }
 
-my $Archived = $archive ? " Archived" : "";
+my $Archived = $param{archive} ? " Archived" : "";
 
 our $this = munge_url('pkgreport.cgi?',
                      %param,
@@ -339,7 +341,7 @@ if (defined $param{maint} and $param{maint} eq "" or ref($param{maint}) and not
      @bugs = get_bugs(function =>
                      sub {my %d=@_;
                           foreach my $try (splitpackages($d{"pkg"})) {
-                               return 1 if !getparsedaddrs($maintainers{$try});
+                               return 1 if not exists $maintainers{$try};
                           }
                           return 0;
                      }
index f83eabb9a84237e2e9fb7903ebc4ef1a919773e5..ccf1ee7924e8abdfd0450bbe802b61431caf0855 100644 (file)
@@ -228,6 +228,7 @@ while (my ($command,$control_command) = splice(@control_commands,0,2)) {
                              Subject => "Munging a bug with $command",
                             ],
                  body => <<EOF) or fail 'message to control@bugs.something failed';
+debug 10
 $control_command->{command} 1$control_command->{value}
 thanks
 EOF
index 18ccbc5c9cc472dbf759da64d87e74bac9416d41..78fbdc74b4cd3742c30dd088ea1555eeea9492cb 100644 (file)
@@ -78,3 +78,4 @@ ok($mech->content() =~ qr/\<title\>\#1.+Submitting a bug/i,
    'Title of bug is submitting a bug');
 
 # Other tests for bugs in the page should be added here eventually
+
index 3154a0835aa11fcfefca31bef29b2541eaefdd2e..2a04c60e07da530176262ced80b81d4150a16690 100644 (file)
@@ -6,13 +6,6 @@ use Test::More tests => 4;
 use warnings;
 use strict;
 
-# Here, we're going to shoot messages through a set of things that can
-# happen.
-
-# First, we're going to send mesages to receive.
-# To do so, we'll first send a message to submit,
-# then send messages to the newly created bugnumber.
-
 use IO::File;
 use File::Temp qw(tempdir);
 use Cwd qw(getcwd);
@@ -32,7 +25,7 @@ if ($@) {
      BAIL_OUT($@);
 }
 
-# Output some debugging information if there's an error
+# Output some debugging information if we're debugging
 END{
      if ($ENV{DEBUG}) {
          foreach my $key (keys %config) {
@@ -55,7 +48,7 @@ This is a silly bug
 EOF
 
 
-# test bugreport.cgi
+# test the soap server
 
 my $port = 11343;
 
@@ -69,8 +62,10 @@ our $child_pid = undef;
 
 END{
      if (defined $child_pid) {
+         my $temp_exit = $?;
          kill(15,$child_pid);
          waitpid(-1,0);
+         $? = $temp_exit;
      }
 }
 
index 5d04848bf255f71bfe9d3627694ae733280dd2bb..580c41d5ebaa06c199e52f766d0fae39c064987f 100644 (file)
@@ -151,16 +151,16 @@ sub send_message{
      my $output='';
      local $SIG{PIPE} = 'IGNORE';
      local $SIG{CHLD} = sub {};
-     my $pid = open3($wfd,$rfd,$rfd,'scripts/receive.in')
-         or die "Unable to start receive.in: $!";
+     my $pid = open3($wfd,$rfd,$rfd,'scripts/receive')
+         or die "Unable to start receive: $!";
      print {$wfd} create_mime_message($param{headers},
-                                        $param{body}) or die "Unable to to print to receive.in";
-     close($wfd) or die "Unable to close receive.in";
+                                        $param{body}) or die "Unable to to print to receive";
+     close($wfd) or die "Unable to close receive";
      my $err = $? >> 8;
      my $childpid = waitpid($pid,0);
      if ($childpid != -1) {
          $err = $? >> 8;
-         print STDERR "receive.in pid: $pid doesn't match childpid: $childpid\n" if $childpid != $pid;
+         print STDERR "receive pid: $pid doesn't match childpid: $childpid\n" if $childpid != $pid;
      }
      if ($err != 0 ) {
          my $rfh =  IO::Handle->new_from_fd($rfd,'r') or die "Unable to create filehandle: $!";
@@ -171,11 +171,11 @@ sub send_message{
               print STDERR "Reading from STDOUT/STDERR would have blocked.";
          }
          print STDERR $output,qq(\n);
-         die "receive.in failed with exit status $err";
+         die "receive failed with exit status $err";
      }
      # now we should run processall to see if the message gets processed
      if ($param{run_processall}) {
-         system('scripts/processall.in') == 0 or die "processall.in failed";
+         system('scripts/processall') == 0 or die "processall failed";
      }
 }
 
@@ -190,8 +190,10 @@ sub send_message{
      END {
          if (defined $child_pid) {
               # stop the child
+              my $temp_exit = $?;
               kill(15,$child_pid);
               waitpid(-1,0);
+              $? = $temp_exit;
          }
      }