if (not defined $tryref and m/^Bug ?\#(\d+)\D/i) {
$tryref = $1 if $1 > 0;
}
+my $locks = 0;
my $data;
if (defined $tryref) {
- my $bfound;
- ($bfound, $data)= &lockreadbugmerge($tryref);
- if ($bfound and not $data->{archived}) {
- $ref= $tryref;
+ my $locks_recv;
+ ($locks_recv, $data)= &lockreadbugmerge($tryref);
+ $locks += $locks_recv;
+ if ($locks_recv and not $data->{archived}) {
+ $ref= $tryref;
} else {
&sendmessage(create_mime_message(
[From => "$gMaintainerEmail ($gProject $gBug Tracking System)",
for $ref (@process) {
if ($ref != $orgref) {
&unfilelock;
+ $locks--;
$data = &lockreadbug($ref)
|| die "huh ? $ref from $orgref out of ".join(' ',@process);
+ $locks++;
}
$data->{done}= $set_done if defined($set_done);
$data->{forwarded}= $set_forwarded if defined($set_forwarded);
}
appendlog($ref,$msg);
+# unlock the locks we have received
+while ($locks--) {unfilelock();}
## handle control messages at this point, immediately before finishing
my %clonebugs = (-1 => $ref);
# -*- mode: cperl;-*-
# $Id: 05_mail.t,v 1.1 2005/08/17 21:46:17 don Exp $
-use Test::More tests => 120;
+use Test::More tests => 122;
use warnings;
use strict;
$status = read_bug(bug=>2);
ok($status->{subject} eq 'this is a new title','bug 2 retitled at submit@ time');
+send_message(to => '1@bugs.something',
+ headers => [To => '1@bugs.something',
+ From => 'foo@bugs.something',
+ Subject => 'Testing control at 1@bugs.something',
+ ],
+ body => <<EOF) or fail 'message to 1@bugs.something failed';
+Control: retitle -1 this is now the title of bug 1
+EOF
+
+ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Testing control at 1@bugs.something")) == 0,
+ '1@bugs.something message was parsed without errors');
+
+$status = read_bug(bug=>1);
+ok($status->{subject} eq 'this is now the title of bug 1','bug 1 retitled at 1@ time');
+
# now we're going to go through and methododically test all of the control commands.