Module: tools Branch: master Commit: 8fd856d8344e257751469c00277fcb1a33a1afea URL: http://source.winehq.org/git/tools.git/?a=commit;h=8fd856d8344e257751469c002...
Author: Francois Gouget fgouget@codeweavers.com Date: Tue Sep 4 00:11:52 2012 +0200
testbot/lib: Add a CombineKey() method for use with GetItem().
This way we don't need to build a dummy object just to be able to compute the string to use for GetItem(). This also provides symmetry with SplitKey().
---
testbot/lib/ObjectModel/Collection.pm | 8 ++++++++ testbot/lib/WineTestBot/PendingPatchSets.pm | 8 +------- 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/testbot/lib/ObjectModel/Collection.pm b/testbot/lib/ObjectModel/Collection.pm index 9ca2503..3d7f78c 100644 --- a/testbot/lib/ObjectModel/Collection.pm +++ b/testbot/lib/ObjectModel/Collection.pm @@ -236,6 +236,14 @@ sub IsEmpty return scalar(keys %{$self->{Items}}) == 0; }
+sub CombineKey +{ + my $self = shift; + + my $CombinedKey = join("#@#", @_); + return $CombinedKey; +} + sub SplitKey { my $self = shift; diff --git a/testbot/lib/WineTestBot/PendingPatchSets.pm b/testbot/lib/WineTestBot/PendingPatchSets.pm index 998c9d3..1a6b9e5 100644 --- a/testbot/lib/WineTestBot/PendingPatchSets.pm +++ b/testbot/lib/WineTestBot/PendingPatchSets.pm @@ -230,13 +230,7 @@ sub NewSubmission my $PartNo = int($1); my $MaxPartNo = int($2);
- my $DummySet = CreatePendingPatchSets()->Add(); - $DummySet->EMail($Patch->FromEMail); - $DummySet->TotalParts($MaxPartNo); - my $SetKey = $DummySet->GetKey(); - $DummySet = undef; - - my $Set = $self->GetItem($SetKey); + my $Set = $self->GetItem($self->CombineKey($Patch->FromEMail, $MaxPartNo)); if (! defined($Set)) { $Set = $self->Add();