[bugzilla-gnome-org-extensions] Go back to parsing all traces in checksetup--we need to have the information in order to detect dupl
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] Go back to parsing all traces in checksetup--we need to have the information in order to detect dupl
- Date: Thu, 20 Nov 2014 22:12:20 +0000 (UTC)
commit 5d77cd482a65f4976f302d49ab503fbbd67e868b
Author: Max Kanat-Alexander <mkanat everythingsolved com>
Date: Tue Aug 4 23:26:48 2009 -0500
Go back to parsing all traces in checksetup--we need to have the information
in order to detect duplicate traces.
code/install-update_db.pl | 69 +++++++++++++++++++++++++++++++++++++++++++++
lib/TraceParser/Hooks.pm | 2 +-
lib/TraceParser/Trace.pm | 17 +++++------
3 files changed, 78 insertions(+), 10 deletions(-)
---
diff --git a/code/install-update_db.pl b/code/install-update_db.pl
new file mode 100644
index 0000000..818ecc8
--- /dev/null
+++ b/code/install-update_db.pl
@@ -0,0 +1,69 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the Bugzilla Example Plugin.
+#
+# The Initial Developer of the Original Code is Canonical Ltd.
+# Portions created by Canonical Ltd. are Copyright (C) 2009
+# Canonical Ltd. All Rights Reserved.
+#
+# Contributor(s):
+# Max Kanat-Alexander <mkanat bugzilla org>
+
+
+use strict;
+use warnings;
+use Bugzilla;
+use Bugzilla::Install::Util qw(indicate_progress);
+
+use TraceParser::Trace;
+
+my $dbh = Bugzilla->dbh;
+my $has_traces = $dbh->selectrow_array('SELECT 1 FROM trace '
+ . $dbh->sql_limit('1'));
+if (!$has_traces) {
+ print "Parsing traces from comments...\n";
+ my $total = $dbh->selectrow_array('SELECT COUNT(*) FROM longdescs');
+
+ if ($dbh->isa('Bugzilla::DB::Mysql')) {
+ $dbh->{'mysql_use_result'} = 1;
+ }
+
+ my $sth = $dbh->prepare('SELECT bug_id, thetext FROM longdescs');
+ $sth->execute();
+ my $count = 0;
+ my @traces;
+ while (my ($bug_id, $text) = $sth->fetchrow_array) {
+ $count++;
+ my $trace = TraceParser::Trace->parse_from_text($text, $bug_id);
+ push(@traces, $trace) if $trace;
+ indicate_progress({ current => $count, total => $total,
+ every => 100 });
+ }
+
+ my $total_traces = scalar(@traces);
+ print "Parsed $total_traces traces.\n";
+
+ if ($dbh->isa('Bugzilla::DB::Mysql')) {
+ $dbh->{'mysql_use_result'} = 0;
+ }
+
+ print "Inserting parsed traces into DB...\n";
+ $count = 1;
+ $dbh->bz_start_transaction();
+ while (my $trace = shift @traces) {
+ TraceParser::Trace->create($trace);
+ indicate_progress({ current => $count++, total => $total_traces,
+ every => 100 });
+ }
+ $dbh->bz_commit_transaction();
+}
diff --git a/lib/TraceParser/Hooks.pm b/lib/TraceParser/Hooks.pm
index ac3fc5b..ae9e62d 100644
--- a/lib/TraceParser/Hooks.pm
+++ b/lib/TraceParser/Hooks.pm
@@ -32,7 +32,7 @@ our @EXPORT = qw(
sub linkify_comment {
my %params = @_;
my ($text, $bug_id, $match, $replace) = @params{qw(text bug_id match replace)};
- my $trace = TraceParser::Trace->new_or_create_from_text($$text, $bug_id);
+ my $trace = TraceParser::Trace->new_from_text($$text, $bug_id);
return if !$trace;
my $template = Bugzilla->template_inner;
my $match_text = quotemeta($trace->text);
diff --git a/lib/TraceParser/Trace.pm b/lib/TraceParser/Trace.pm
index 6874000..ae24244 100644
--- a/lib/TraceParser/Trace.pm
+++ b/lib/TraceParser/Trace.pm
@@ -87,7 +87,7 @@ use constant IGNORE_FUNCTIONS => qw(
# Returns a hash suitable for passing to create(), or undef if there is no
# trace in the comment.
sub parse_from_text {
- my ($class, $text) = @_;
+ my ($class, $text, $bug_id) = @_;
my $trace = Parse::StackTrace->parse(types => TRACE_TYPES,
text => $text);
return undef if !$trace;
@@ -114,6 +114,7 @@ sub parse_from_text {
my $trace_hash = md5_base64($trace_text);
return {
+ bug_id => $bug_id,
stack_hash => $stack_hash,
short_hash => $short_hash,
short_stack => join(', ', @short_stack),
@@ -124,21 +125,19 @@ sub parse_from_text {
};
}
-sub new_or_create_from_text {
+sub new_from_text {
my ($class, $text, $bug_id) = @_;
my $parsed = Parse::StackTrace->parse(types => TRACE_TYPES,
text => $text);
return undef if !$parsed;
my $hash = md5_base64($parsed->text);
my $traces = $class->match({ trace_hash => $hash, bug_id => $bug_id });
- my $trace = $traces->[0];
- if (!$trace) {
- my $data = $class->parse_from_text($text);
- $trace = $class->create({ %$data, bug_id => $bug_id });
+ if (@$traces) {
+ $traces->[0]->{stacktrace_object} = $parsed;
+ return $traces->[0];
}
-
- $trace->{stacktrace_object} = $parsed;
- return $trace;
+ warn "No trace found on bug $bug_id with hash $hash";
+ return undef;
}
###############################
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]