From 3c19ae3fccbef017e52230e54c571055e38b6b19 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 29 Jun 2009 21:03:34 -0700 Subject: [PATCH] Allow for tag nnn = baz + foo - bar in service (closes: #505189) --- debian/changelog | 1 + scripts/service | 65 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/debian/changelog b/debian/changelog index db2ec6b..971d13e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -250,6 +250,7 @@ debbugs (2.4.2~exp0) UNRELEASED; urgency=low (closes: #528249) * Properly html_escape un-processed parts in maybelink (closes: #530506) * Add urls to the bottom of all messages we send out (closes: #9596) + * Allow for tag nnn = baz + foo - bar in service (closes: #505189) -- Colin Watson Fri, 20 Jun 2003 18:57:25 +0100 diff --git a/scripts/service b/scripts/service index 3756625..ff73878 100755 --- a/scripts/service +++ b/scripts/service @@ -778,29 +778,48 @@ END print {$transcript} "Failed to set severity of $config{bug} $ref to $newseverity: ".cleanup_eval_fail($@,$debug)."\n"; } } - } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) { - ### TODO: [#505189] Consider altering this to accept tag #nnn + foo - bar - baz + } elsif (m/^tags?\s+\#?(-?\d+)\s+(\S.*)$/i) { $ok++; $ref = $1; $ref = $clonebugs{$ref} if exists $clonebugs{$ref}; $bug_affected{$ref}=1; - my $addsubcode = $3; - my @add_remove_option = (); - if (defined $addsubcode) { - if ($addsubcode eq '-') { - push @add_remove_option,(remove => 1); - } - elsif ($addsubcode eq '+') { - push @add_remove_option,(add => 1); - } - } - my $tags = $4; + my $tags = $2; my @tags = split /[\s,]+/, $tags; - my @badtags = (); - foreach my $tag (@tags) { + # this is an array of hashrefs which contain two elements, the + # first of which is the array of tags, the second is the + # option to pass to set_tags (we use a hashref here to make it + # more obvious what is happening) + my @tag_operations = {tags => [], + option => [] + }; + my $alter_type = '='; + my @badtags; + for my $tag (@tags) { + if ($tag =~ /^[=+-]$/) { + if ($tag eq '=') { + @tag_operations = {tags => [], + option => [], + }; + } + elsif ($tag eq '-') { + push @tag_operations, + {tags => [], + option => [remove => 1], + }; + } + elsif ($tag eq '+') { + push @tag_operations, + {tags => [], + option => [add => 1] + }; + } + next; + } if (not defined first {$_ eq $tag} @{$config{tags}}) { push @badtags, $tag; + next; } + push @{$tag_operations[-1]{tags}},$tag; } if (@badtags) { print {$transcript} "Unknown tag/s: ".join(', ', @badtags).".\n". @@ -808,13 +827,15 @@ END $errors++; } eval { - set_tags(@common_control_options, - bug => $ref, - tags => [@tags], - warn_on_bad_tags => 0, # don't warn on bad tags, - # 'cause we do that above - @add_remove_option, - ); + for my $operation (@tag_operations) { + set_tags(@common_control_options, + bug => $ref, + tags => [@{$operation->{$tags}}], + warn_on_bad_tags => 0, # don't warn on bad tags, + # 'cause we do that above + @{$operation->{option}}, + ); + } }; if ($@) { # we intentionally have two errors here if there is a bad -- 2.39.2