[bugzilla-gnome-org-extensions] Also format Python traces.



commit ac23011636863c15d4ec8126a9072d07663f1bf7
Author: Max Kanat-Alexander <mkanat everythingsolved com>
Date:   Wed Aug 5 06:45:01 2009 -0500

    Also format Python traces.

 lib/TraceParser/Hooks.pm                   |    6 +++---
 lib/TraceParser/Trace.pm                   |   14 ++++++++++----
 template/en/default/pages/trace.html.tmpl  |    7 ++++++-
 template/en/default/trace/format.html.tmpl |   22 +++++++++++++++++++++-
 web/style.css                              |    9 +++++++--
 5 files changed, 47 insertions(+), 11 deletions(-)
---
diff --git a/lib/TraceParser/Hooks.pm b/lib/TraceParser/Hooks.pm
index 46928a5..139cb0c 100644
--- a/lib/TraceParser/Hooks.pm
+++ b/lib/TraceParser/Hooks.pm
@@ -22,6 +22,7 @@
 package TraceParser::Hooks;
 use strict;
 use base qw(Exporter);
+use Bugzilla::Error;
 use Bugzilla::Install::Util qw(indicate_progress);
 use TraceParser::Trace;
 
@@ -38,14 +39,14 @@ sub install_update_db {
     return if $has_traces;
 
     print "Parsing traces from comments...\n";
-    my $total = 75000; #$dbh->selectrow_array('SELECT COUNT(*) FROM longdescs');
+    my $total = 100000; #$dbh->selectrow_array('SELECT COUNT(*) FROM longdescs');
 
     if ($dbh->isa('Bugzilla::DB::Mysql')) {
         $dbh->{'mysql_use_result'} = 1;
     }
 
     my $sth = $dbh->prepare('SELECT comment_id, thetext FROM longdescs 
-                           ORDER BY comment_id DESC LIMIT 75000');
+                           ORDER BY comment_id DESC LIMIT 100000');
     $sth->execute();
     my $count = 1;
     my @traces;
@@ -93,7 +94,6 @@ sub format_comment {
     }
     else {
         my $stacktrace = TraceParser::Trace->stacktrace_from_text($$text);
-        $trace->{stack} = $stacktrace;
         $match_text = $stacktrace->text;
     }
 
diff --git a/lib/TraceParser/Trace.pm b/lib/TraceParser/Trace.pm
index b0f3ddf..8cc96e9 100644
--- a/lib/TraceParser/Trace.pm
+++ b/lib/TraceParser/Trace.pm
@@ -47,7 +47,7 @@ use constant DB_COLUMNS => qw(
 
 use constant DB_TABLE => 'trace';
 
-use constant LIST_ORDER => 'comment_id';
+use constant LIST_ORDER => 'quality DESC, comment_id';
 
 use constant VALIDATORS => {
     stack_hash  => \&_check_hash,
@@ -77,6 +77,7 @@ use constant IGNORE_FUNCTIONS => qw(
    __libc_start_main
    raise
    abort
+   poll
    ??
 );
 
@@ -125,7 +126,9 @@ sub parse_from_text {
 
     my $stack_hash;
     my $short_hash;
-    if (@all_functions) {
+    # We don't do similarity on traces that have fewer than 2 functions
+    # in their stack.
+    if (@all_functions > 1) {
         my $max_short_stack = $#all_functions >= STACK_SIZE ? STACK_SIZE 
                               : $#all_functions;
         my @short_stack = @all_functions[0..($max_short_stack-1)];
@@ -155,7 +158,10 @@ sub short_hash  { return $_[0]->{short_hash};  }
 sub trace_hash  { return $_[0]->{trace_hash};  }
 sub text        { return $_[0]->{trace_text};  }
 sub type        { return $_[0]->{type};        }
-sub quality     { return $_[0]->{quality};     }
+sub quality     {
+    my $self = shift;
+    return sprintf('%.1f', $self->{quality});
+}
 
 sub bug {
     my $self = shift;
@@ -171,7 +177,7 @@ sub stack {
     my $self = shift;
     my $type = $self->type;
     eval("use $type; 1;") or die $@;
-    $self->{stack} ||= $type->parse({ text => $self->trace_text });
+    $self->{stack} ||= $type->parse(text => $self->text);
     return $self->{stack};
 }
 
diff --git a/template/en/default/pages/trace.html.tmpl b/template/en/default/pages/trace.html.tmpl
index efb56b1..f0a7e47 100644
--- a/template/en/default/pages/trace.html.tmpl
+++ b/template/en/default/pages/trace.html.tmpl
@@ -47,11 +47,16 @@
         <a href="page.cgi?id=trace.html&amp;trace_id=
                  [%- this_trace.id FILTER url_quote %]">Trace 
           [% this_trace.id FILTER html %]</a> on
-        [%+ "Bug $bug.id" FILTER bug_link(bug.id) %]
+        [%+ "Bug $bug.id" FILTER bug_link(bug.id) %]:
+        [% bug.bug_status FILTER html %] [%+ bug.resolution FILTER html %]
+        [% IF bug.dup_id %]
+          of [% "bug $bug.dup_id" FILTER bug_link(bug.dup_id) %]
+        [% END %]
         (Quality: [% this_trace.quality FILTER html %])
         [% IF user.can_see_bug(bug) %]
           [%+ bug.product FILTER html %]
         [% END %]
+        
       </li>
     [% END %]
   </ul>
diff --git a/template/en/default/trace/format.html.tmpl b/template/en/default/trace/format.html.tmpl
index 4f39dd6..c9e9449 100644
--- a/template/en/default/trace/format.html.tmpl
+++ b/template/en/default/trace/format.html.tmpl
@@ -27,6 +27,26 @@
 <table border="0" cellpadding="0" cellspacing="0"><tr><td>
 <div class="trace">
   [% IF trace.type.match('Python') %]
+    <ul class="frames">
+      [% SET thread = trace.stack.threads.0 %]
+      [% FOREACH frame = thread.frames.reverse %]
+        <li class="frame">
+          File "<span class="frame_file">[% frame.file FILTER html %]</span>",
+          line <span class="frame_line">[% frame.line FILTER html %]</span>
+          [% IF frame.function %]
+            in <span class="frame_function">
+                 [%- frame.function FILTER html %]</span>
+          [% END %]
+          [% IF frame.code %]
+            <pre class="frame_code">[% frame.code FILTER html %]</pre>
+          [% END %]
+        </li>
+      [% END %]
+    </ul>
+    [% IF thread.description %]
+      <span class="thread_description">
+        [%- thread.description FILTER html %]</span>
+    [% END %]
   [% ELSE %]
     [% SET st = trace.stack %]
     [% IF st.thread_with_crash %]
@@ -37,7 +57,7 @@
     
     [% FOREACH thread = threads %]
       [% IF thread.number || thread.description %]
-        <p class="thread_start">Thread [% thread.number FILTER html %] 
+        <p class="thread_description">Thread [% thread.number FILTER html %] 
           ([% thread.description FILTER html %])</p>
       [% END %]
 
diff --git a/web/style.css b/web/style.css
index cf193d9..a88fe9f 100644
--- a/web/style.css
+++ b/web/style.css
@@ -3,7 +3,7 @@
     margin-top: -.5em;
 }
 
-.thread_start {
+.thread_description {
   font-weight: bold;
   margin-top: 0;
 }
@@ -31,9 +31,14 @@
   color: #4e9a06;
 }
 
-.frame_file_container, .frame_library_container {
+.frame_code, .frame_file_container, .frame_library_container {
   margin-left: 2em;
 }
+.frame_code {
+  display: block;
+  margin-top: 0;
+  margin-bottom: 0;
+}
 
 .frame_file, .frame_library {
   font-style: italic;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]