From 0ee02c0279517257feecad7ae787b9c49d8710da Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 30 Dec 2006 07:16:22 +0000 Subject: Bug 363371: It is hard to determine which row has a failed encoding, with recode.pl --guess Patch By Max Kanat-Alexander r=justdave, a=justdave --- contrib/recode.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/recode.pl b/contrib/recode.pl index 741c62e2a..49e824f6d 100755 --- a/contrib/recode.pl +++ b/contrib/recode.pl @@ -251,6 +251,13 @@ foreach my $table ($dbh->bz_table_list_real) { my $data = shift @result; my $digest = md5_base64($data); + my @primary_keys = reverse split(',', $pk); + # We copy the array so that we can pop things from it without + # affecting the original. + my @pk_data = @result; + my $pk_line = join (', ', + map { "$_ = " . pop @pk_data } @primary_keys); + my $encoding; if ($switch{'guess'}) { $encoding = do_guess($data); @@ -261,7 +268,8 @@ foreach my $table ($dbh->bz_table_list_real) { && !is_valid_utf8($data)) { my $truncated = trunc($data); - print "Failed to guess: Key: $digest", + print "Row: [$pk_line]\n", + "Failed to guess: Key: $digest", " DATA: $truncated\n"; } @@ -283,7 +291,8 @@ foreach my $table ($dbh->bz_table_list_real) { if ($encoding && !grep($_ eq $encoding, IGNORE_ENCODINGS)) { my $decoded = encode('utf8', decode($encoding, $data)); if ($switch{'dry-run'} && $data ne $decoded) { - print "From: [" . trunc($data) . "] Key: $digest\n", + print "Row: [$pk_line]\n", + "From: [" . trunc($data) . "] Key: $digest\n", "To: [" . trunc($decoded) . "]", " Encoding : $encoding\n"; } -- cgit v1.2.3-24-g4f1b