[bugzilla-gnome-org-extensions] A tool to re-hash the traces if you change the code that determines what to hash.



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

    A tool to re-hash the traces if you change the code that determines
    what to hash.

 rehash-traces.pl |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/rehash-traces.pl b/rehash-traces.pl
new file mode 100755
index 0000000..2f23739
--- /dev/null
+++ b/rehash-traces.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use lib qw(. lib extensions/traceparser/lib);
+use Bugzilla;
+use Bugzilla::Install::Util qw(indicate_progress);
+use TraceParser::Trace;
+
+my $dbh = Bugzilla->dbh;
+
+print "Re-parsing traces...\n";
+my $total = $dbh->selectrow_array('SELECT COUNT(*) FROM trace');
+    
+if ($dbh->isa('Bugzilla::DB::Mysql')) {
+    $dbh->{'mysql_use_result'} = 1;
+}
+    
+my $sth = $dbh->prepare('SELECT id,trace_text FROM trace ORDER BY id');
+$sth->execute();
+my $count = 0;
+my @traces;
+while (my ($id, $text) = $sth->fetchrow_array) {
+    $count++;
+    my $trace = TraceParser::Trace->parse_from_text($text);
+    indicate_progress({ current => $count, total => $total, every => 10 });
+    $trace->{id} = $id;
+    push(@traces, $trace);
+}
+
+if ($dbh->isa('Bugzilla::DB::Mysql')) {
+    $dbh->{'mysql_use_result'} = 0;
+}
+
+$dbh->bz_start_transaction();
+print "Updating trace hashes...\n";
+$count = 1;
+foreach my $trace (@traces) {
+    $dbh->do("UPDATE trace SET stack_hash = ?, short_hash = ? WHERE id = ?",
+             undef, $trace->{stack_hash}, $trace->{short_hash}, $trace->{id});
+    indicate_progress({ current => $count, total => $total, every => 10 });
+}
+$dbh->bz_commit_transaction();


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