Francois Gouget : testbot: Share the patch subject parsing code.
Alexandre Julliard
julliard at winehq.org
Tue Feb 25 16:02:34 CST 2020
Module: tools
Branch: master
Commit: 02540eb65d19d926b7b20051f2e7af4f2a672489
URL: https://source.winehq.org/git/tools.git/?a=commit;h=02540eb65d19d926b7b20051f2e7af4f2a672489
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Feb 25 00:14:24 2020 +0100
testbot: Share the patch subject parsing code.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48353
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/lib/WineTestBot/Patches.pm | 73 ++++++++++++++++-------------
testbot/lib/WineTestBot/PendingPatchSets.pm | 24 ++++------
2 files changed, 50 insertions(+), 47 deletions(-)
diff --git a/testbot/lib/WineTestBot/Patches.pm b/testbot/lib/WineTestBot/Patches.pm
index 6af51d7..2b52f4b 100644
--- a/testbot/lib/WineTestBot/Patches.pm
+++ b/testbot/lib/WineTestBot/Patches.pm
@@ -110,6 +110,31 @@ sub FromSubmission($$)
$self->Disposition("Processing");
}
+sub ParseSubject($)
+{
+ my ($self) = @_;
+
+ my $Title = $self->Subject;
+ $Title =~ s/32\/64//;
+ $Title =~ s/64\/32//;
+
+ my $SubjectInfo;
+ if ($Title =~ s~[[\(](\d+)/(\d+)[]\)]~~ or
+ $Title =~ s~\b(\d+)/(\d+)\b~~)
+ {
+ $SubjectInfo->{PartNo} = int($1);
+ $SubjectInfo->{MaxPartNo} = int($2);
+ }
+
+ $Title =~ s/\[PATCH[^]]*\]//i;
+ $Title =~ s/\s+/ /g;
+ $Title =~ s/^\s//;
+ $Title =~ s/\s$//;
+ $SubjectInfo->{Title} = $Title;
+
+ return $SubjectInfo;
+}
+
=pod
=over 12
@@ -129,22 +154,23 @@ WineTestBot::PendingPatchSet::SubmitSubset().
=back
=cut
-sub Submit($$$)
+sub Submit($$;$)
{
- my ($self, $PatchFileName, $IsSet) = @_;
+ my ($self, $PatchFileName, $SubjectInfo) = @_;
+ $SubjectInfo ||= $self->ParseSubject();
my $Impacts = GetPatchImpacts($PatchFileName);
if (!$Impacts->{PatchedRoot} and !$Impacts->{PatchedModules} and
!$Impacts->{PatchedTests})
{
if ($Impacts->{IsWinePatch})
{
- $self->Disposition(($IsSet ? "Part does" : "Does")
+ $self->Disposition(($SubjectInfo->{PartNo} ? "Part does" : "Does")
." not impact the Wine build");
}
else
{
- $self->Disposition(($IsSet ? "Part is not" : "Not") ." a Wine patch");
+ $self->Disposition(($SubjectInfo->{PartNo} ? "Part is not" : "Not") ." a Wine patch");
}
return undef;
}
@@ -155,12 +181,8 @@ sub Submit($$$)
my $Priority = 5;
$NewJob->Priority($Priority);
my $PropertyDescriptor = $Jobs->GetPropertyDescriptorByName("Remarks");
- my $Subject = $self->Subject;
- $Subject =~ s/\[PATCH[^\]]*]//i;
- $Subject =~ s/[[\(]?\d+\/\d+[\)\]]?//;
- $Subject =~ s/^\s*//;
- $NewJob->Remarks(substr("[$PatchesMailingList] " . $Subject, 0,
- $PropertyDescriptor->GetMaxLength()));
+ my $Remarks = "[$PatchesMailingList] $SubjectInfo->{Title}";
+ $NewJob->Remarks(substr($Remarks, 0, $PropertyDescriptor->GetMaxLength()));
$NewJob->Patch($self);
my $User;
@@ -301,7 +323,7 @@ sub Submit($$$)
}
else
{
- $self->Disposition(($IsSet ? "Part does" : "Does") ." not impact the ".
+ $self->Disposition(($SubjectInfo->{PartNo} ? "Part does" : "Does") ." not impact the ".
($WineVMs->IsEmpty() ? "Windows " : "") ."tests");
}
return undef;
@@ -464,28 +486,15 @@ sub NewPatch($$$)
my $ErrMessage;
if (scalar(@PatchBodies) == 1)
{
- my $Subject = $Patch->Subject;
- $Subject =~ s/32\/64//;
- $Subject =~ s/64\/32//;
- if ($Subject =~ m/\d+\/\d+/)
- {
- $Patch->Disposition("Checking series");
- (my $_ErrKey, my $_ErrProperty, $ErrMessage) = $self->Save();
- link($PatchBodies[0]->path, "$DataDir/patches/" . $Patch->Id);
- if (! defined($ErrMessage))
- {
- $ErrMessage = CreatePendingPatchSets()->NewSubmission($Patch);
- }
- }
- else
+ my $SubjectInfo = $Patch->ParseSubject();
+ $Patch->Disposition($SubjectInfo->{PartNo} ? "Checking series" : "Checking patch");
+ (my $_ErrKey, my $_ErrProperty, $ErrMessage) = $self->Save();
+ link($PatchBodies[0]->path, "$DataDir/patches/" . $Patch->Id);
+ if (!defined $ErrMessage)
{
- $Patch->Disposition("Checking patch");
- (my $_ErrKey, my $_ErrProperty, $ErrMessage) = $self->Save();
- link($PatchBodies[0]->path, "$DataDir/patches/" . $Patch->Id);
- if (! defined($ErrMessage))
- {
- $ErrMessage = $Patch->Submit($PatchBodies[0]->path, !1);
- }
+ $ErrMessage = $SubjectInfo->{PartNo} ?
+ CreatePendingPatchSets()->NewSubmission($Patch, $SubjectInfo) :
+ $Patch->Submit($PatchBodies[0]->path, $SubjectInfo);
}
}
elsif (scalar(@PatchBodies) == 0)
diff --git a/testbot/lib/WineTestBot/PendingPatchSets.pm b/testbot/lib/WineTestBot/PendingPatchSets.pm
index 5339513..adabf2e 100644
--- a/testbot/lib/WineTestBot/PendingPatchSets.pm
+++ b/testbot/lib/WineTestBot/PendingPatchSets.pm
@@ -136,7 +136,7 @@ sub SubmitSubset($$$)
if (!defined $ErrMessage)
{
- $ErrMessage = $FinalPatch->Submit($CombinedFileName, 1);
+ $ErrMessage = $FinalPatch->Submit($CombinedFileName);
}
unlink($CombinedFileName);
@@ -224,36 +224,29 @@ makes the patchset complete, then the patchset itself is deleted.
=back
=cut
-sub NewSubmission($$)
+sub NewSubmission($$$)
{
- my ($self, $Patch) = @_;
+ my ($self, $Patch, $SubjectInfo) = @_;
if (! defined($Patch->FromEMail))
{
$Patch->Disposition("Unable to determine series author");
return undef;
}
- my $Subject = $Patch->Subject;
- $Subject =~ s/32\/64//;
- $Subject =~ s/64\/32//;
- $Subject =~ m/(\d+)\/(\d+)/;
- my $PartNo = int($1);
- my $MaxPartNo = int($2);
-
- my $Set = $self->GetItem($self->CombineKey($Patch->FromEMail, $MaxPartNo));
+ my $Set = $self->GetItem($self->CombineKey($Patch->FromEMail, $SubjectInfo->{MaxPartNo}));
if (! defined($Set))
{
$Set = $self->Add();
$Set->EMail($Patch->FromEMail);
- $Set->TotalParts($MaxPartNo);
+ $Set->TotalParts($SubjectInfo->{MaxPartNo});
}
my $Parts = $Set->Parts;
- my $Part = $Parts->GetItem($PartNo);
+ my $Part = $Parts->GetItem($SubjectInfo->{PartNo});
if (! defined($Part))
{
$Part = $Parts->Add();
- $Part->No($PartNo);
+ $Part->No($SubjectInfo->{PartNo});
}
$Part->Patch($Patch);
@@ -264,12 +257,13 @@ sub NewSubmission($$)
$Patch->Disposition("Error occurred during series processing");
}
- if (! $Set->CheckSubsetComplete($PartNo))
+ if (! $Set->CheckSubsetComplete($SubjectInfo->{PartNo}))
{
$Patch->Disposition("Set not complete yet");
}
else
{
+ my $PartNo = $SubjectInfo->{PartNo};
my $AllPartsAvailable = 1;
while ($PartNo <= $Set->TotalParts && $AllPartsAvailable &&
! defined($ErrMessage))
More information about the wine-cvs
mailing list