From owner-svn-src-user@FreeBSD.ORG Tue Feb 19 02:28:36 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CF69132A; Tue, 19 Feb 2013 02:28:36 +0000 (UTC) (envelope-from linimon@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A8A29662; Tue, 19 Feb 2013 02:28:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1J2SaUr016043; Tue, 19 Feb 2013 02:28:36 GMT (envelope-from linimon@svn.freebsd.org) Received: (from linimon@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1J2SaAO016042; Tue, 19 Feb 2013 02:28:36 GMT (envelope-from linimon@svn.freebsd.org) Message-Id: <201302190228.r1J2SaAO016042@svn.freebsd.org> From: Mark Linimon Date: Tue, 19 Feb 2013 02:28:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r246963 - user/bugmeister/gnats/tools X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2013 02:28:36 -0000 Author: linimon (doc,ports committer) Date: Tue Feb 19 02:28:36 2013 New Revision: 246963 URL: http://svnweb.freebsd.org/changeset/base/246963 Log: Production code refactored from www/en/cgi/query-pr-summary.cgi. Added: user/bugmeister/gnats/tools/query-pr-common.pl (contents, props changed) Added: user/bugmeister/gnats/tools/query-pr-common.pl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/bugmeister/gnats/tools/query-pr-common.pl Tue Feb 19 02:28:36 2013 (r246963) @@ -0,0 +1,572 @@ +#!/usr/bin/perl +# refactored from www/en/cgi/query-pr-summary.cgi + +$project = 'FreeBSD'; +$mail_prefix = 'freebsd-'; +$mail_unass = 'freebsd-bugs'; +$ports_unass = 'ports-bugs'; + +# put these in each of your .cgi files +#require '/c/gnats/tools/cgi-lib.pl'; +#require '/c/gnats/tools/cgi-style.pl'; +#require '/c/gnats/tools/query-pr-common.pl'; +#require 'getopts.pl'; + +%mons = ('Jan', '01', 'Feb', '02', 'Mar', '03', + 'Apr', '04', 'May', '05', 'Jun', '06', + 'Jul', '07', 'Aug', '08', 'Sep', '09', + 'Oct', '10', 'Nov', '11', 'Dec', '12'); + +$table = ""; +$table_e = '
'; + +# Customizations for the look and feel of the summary tables. +$t_style = ""; + +sub escape($) { $_ = $_[0]; s/&/&/g; s//>/g; $_; } + +sub cgiparam { + local ($result) = @_; + + $result =~ s/[^A-Za-z0-9+.@-]/"%".sprintf("%02X", unpack("C", $&))/ge; + $result; +} + +# XXX not yet tested +# XXX added input as param +# XXX added html_mode as param +sub header_info { + local($input) = @_[0]; + local($html_mode) = @_[1]; + + if ($html_mode) { + print &html_header("Current $project problem reports"); + } + else { + if (!$input{'very_quiet'}) { + print "Current $project problem reports\n"; + } + } +# XXX MCL 20081013 +# if (!$input{'quiet'}) { +# print "The following is a listing of current problems submitted by $project users. " . +# 'These represent problem reports covering all versions including ' . +# 'experimental development code and obsolete releases. '; +# +# &header_info_states($html_mode); +# } +# print "

\n"; +} + +sub header_info_states { + local($html_mode) = @_[0]; + + if ($html_mode) { + print < +Bugs can be in one of several states: +

+
+
o - open
+
A problem report has been submitted, no sanity checking +performed.
+ +
a - analyzed
+
The problem is understood and a solution is being sought.
+ +
f - feedback
+
Further work requires additional information from the originator +or the community - possibly confirmation of the effectiveness of a +proposed solution.
+ +
p - patched
+
A patch has been committed, but some issues (MFC and / or +confirmation from originator) are still open.
+ +
r - repocopy
+
The resolution of the problem report is dependent on a repocopy +operation within the CVS repository which is awaiting completion.
+ +
s - suspended
+
The problem is not being worked on, due to lack of information or +resources. This is a prime candidate for somebody who is looking for a +project to do. If the problem cannot be solved at all, it will be +closed, rather than suspended.
+ +
c - closed
+
A problem report is closed when any changes have been integrated, +documented, and tested -- or when fixing the problem is abandoned.
+
+EOM + +# 20080915 test: declare this boilerplate obsolete +# } else { +# +#print </>/g; + + $line; +} + +sub printcnt { + local($cnt) = $_[0]; + + if ($cnt) { + printf("%d problem%s total.\n", $cnt, $cnt == 1 ? '' : 's'); + } else { + print("(none)\n"); + } +} + +# XXX not yet used +# XXX add htmlmode as param +# XXX add catdesc as param +# XXX add cat as param +# XXX add prs as param +# XXX add query_pr_ref as param +sub cat_summary { + &get_categories; + foreach (keys %status) { + s|/\d+||; + $cat{$_}++; + } + foreach (@categories) { + next unless $cat{$_}; # skip categories with no bugs. + if ($htmlmode) { + print "

Problems in category: $_ ($catdesc{$_})

\n"; + } else { + print "Problems in category: $_ ($catdesc{$_})\n"; + } + if (/^(\w+)/) { + &printcnt(&gnats_summary("\$cat eq \"$1\"", $html_mode, \@prs, $query_pr_ref)); + } else { + print "\n??? weird category $_\n"; + } + } +} + +# XXX not yet used +# XXX add html_mode as param +# XXX add who as param +# XXX add resp as param +# XXX add prs as param +# XXX add query_pr_ref as param +sub resp_summary { + local($who, %who); + + foreach (keys %resp) { + $who{$resp{$_}}++; + } + foreach $who (sort keys %who) { + $cnt = &gnats_summary("\$resp eq \"$who\"", $html_mode, \@prs, $query_pr_ref); + } +} + +# XXX not yet used +# XXX add html_mode as param +# XXX add input as param +# XXX add state as param +# XXX add prs as param +# XXX add query_pr_ref as param +sub state_summary { + &get_states; + foreach (@states) { + next if ($_ eq "closed" && !$input{"closedtoo"}); + if ($htmlmode) { + print "

Problems in state: $_

\n"; + } else { + print "Problems in state: $_$\n"; + } + if (/^(\w)/) { + &printcnt(&gnats_summary("\$state eq \"$1\" ", $html_mode, \@prs, $query_pr_ref)); + } else { + print "\n??? bad state $state\n"; + } + } +} + +# XXX not yet used +# XXX add html_mode as param +# XXX add prs as param +# XXX add query_pr_ref as param +sub severity_summary { + if ($htmlmode) { + print "

Critical problems

\n"; + } else { + print "Critical problems\n"; + } + &printcnt(&gnats_summary('$severity eq "critical"', $html_mode, \@prs, $query_pr_ref)); + + if ($htmlmode) { + print "

Serious problems

\n"; + } else { + print "Serious problems\n"; + } + &printcnt(&gnats_summary('$severity eq "serious"', $html_mode, \@prs, $query_pr_ref)); + + if ($htmlmode) { + print "

Non-critical problems

\n"; + } else { + print "Non-critical problems\n"; + } + &printcnt(&gnats_summary('$severity eq "non-critical"', $html_mode, \@prs, $query_pr_ref)); +} + +sub get_categories { + @categories = (); + + open(Q, 'query-pr --list-categories 2>/dev/null |') || + die "Cannot get categories\n"; + + while() { + chop; + local ($cat, $desc, $responsible, $notify) = split(/:/); + push(@categories, $cat); + $catdesc{$cat} = $desc; + } +} + +# XXX not yet used +# XXX statedesc? +sub get_states { + @states = (); + + open(Q, 'query-pr --list-states 2>/dev/null |') || + die "Cannot get states\n"; + + while() { + chop; + local ($state, $type, $desc) = split(/:/); + push(@states, $state); + $statedesc{$state} = $desc; + } +} + +# XXX not yet used +# XXX classdesc? +sub get_classes { + @classes = (); + + open(Q, 'query-pr --list-classes 2>/dev/null |') || + die "Cannot get classes\n"; + + while() { + chop; + local ($class, $type, $desc) = split(/:/); + push(@classes, $class); + $classdesc{$class} = $desc; + } +} + +# XXX now returns @prs +sub read_gnats { +# XXX MCL these next two changes STILL do not do what I want!!! +# local($report) = @_[0]; + local($report) = @_; + $report=~s/"//g; + +#print "query-pr $report 2>/dev/null |"; + + open(Q, "query-pr $report 2>/dev/null |") || die "Cannot query the PR's\n"; + + while() { + chop; + if(/^>Number:/) { + $number = &getline($_); +#print $number; + + } elsif (/Arrival-Date:/) { + $date = &getline($_); + # strip timezone if any (between HH:MM:SS and YYYY at end of line): + $date =~ s/(\d\d:\d\d:\d\d)\D+(\d{4})$/\1 \2/; + ($dow,$mon,$day,$time,$year,$xtra) = split(/[ \t]+/, $date); + $day = "0$day" if $day =~ /^[0-9]$/; + $date = "$year/$mons{$mon}/$day"; + + } elsif (/>Last-Modified:/) { + $lastmod = &getline($_); + if ($lastmod =~ /^[ ]*$/) { + $lastmod = $date; + } else { + # strip timezone if any (between HH:MM:SS and YYYY at end of line): + $lastmod =~ s/(\d\d:\d\d:\d\d)\D+(\d{4})$/\1 \2/; + ($dow,$mon,$day,$time,$year,$xtra) = split(/[ \t]+/, $lastmod); + $day = "0$day" if $day =~ /^[0-9]$/; + $lastmod = "$year/$mons{$mon}/$day"; + } + + } elsif (/>Category:/) { + $cat = &getline($_); + + } elsif (/>Severity:/) { + $sev = &getline($_); + + } elsif (/>Responsible:/) { + $resp = &getline($_); + $resp =~ s/@.*//; + $resp =~ tr/A-Z/a-z/; + $resp = "" if (($resp =~ /$mail_unass/o) or ($resp =~ /$ports_unass/o)); + $resp =~ s/^$mail_prefix//; + + } elsif (/>State:/) { + $status = &getline($_); + $status =~ s/(.).*/\1/; + + } elsif (/>Synopsis:/) { + $syn = &getline($_); + $syn =~ s/[\t]+/ /g; + + } elsif (/^$/) { + $_ = sprintf("%s/%s", $cat, $number); + + $status{$_} = $status; + $date{$_} = $date; + $resp{$_} = $resp; + $syn{$_} = $syn; + $sev{$_} = $sev; + $lastmod{$_} = $lastmod; + push(@prs,$_); + } + } + close(Q); + + @prs; +} + +# XXX changed to use address of prs as param 2 +# XXX add query_pr_ref as param +sub gnats_summary { + local($report) = @_[0]; + local($htmlmode) = @_[1]; + local($prs) = @_[2]; + local($counter) = 0; + + foreach (@{$prs}) { + $state = $status{$_}; + $date = $date{$_}; + $resp = $resp{$_}; + $syn = $syn{$_}; + $severity = $sev{$_}; + ($cat, $number) = m|^([^/]+)/(\d+)$|; + + next if (($report ne '') && (eval($report) == 0)); + + if ($htmlmode) { + $title = "$_"; + $syn = &html_fixline($syn); + gnats_summary_line_html($counter, $state, $date, $title, $resp, $syn); + } else { + $title = substr($cat,0,5) . '/' . $number; + gnats_summary_line_text($counter, $state, $date, $title, $resp, $syn); + } + + $counter++; + } + + if ($htmlmode) { + print "${table_e}\n" if $counter; + } else { + print "\n" if $counter; + } + + $counter; +} + +sub gnats_summary_line_html { + local($counter) = shift; + local($state) = shift; + local($date) = shift; + local($title) = shift; + local($resp) = shift; + local($syn) = shift; + + if ($counter == 0) { + print "$tableSSubmittedTrackerResp.Description\n" + } + + print "$state$date$title$resp$syn\n"; +} + +sub gnats_summary_line_text { + local($counter) = shift; + local($state) = shift; + local($date) = shift; + local($title) = shift; + local($resp) = shift; + local($syn) = shift; + + # Print the banner line if this is the first iteration. + print "S Tracker Resp. Description\n" . + "----------------------------------------" . + "----------------------------------------\n" + if ($counter == 0); + print "$state " . + $title . (' ' x (13 - length($title))) . + $resp . (' ' x (11 - length($resp))) . + substr($syn,0,54) . "\n"; +} + +# XXX not yet used +# XXX add self_ref as param +sub displayform { +print qq` +

+Please select the items you wish to search for. Multiple items are AND'ed +together. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Category:Severity:
Priority:Class:
State:Sort by:
Text in single-line fields:Responsible:
Text in multi-line fields:Originator:
Closed reports too:Release:
+ + +
+`; +}