[Tools] testbot/lib: Add a CombineKey() method for use with GetItem().

Francois Gouget fgouget at codeweavers.com
Mon Sep 3 17:11:52 CDT 2012


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();
-- 
1.7.10.4




More information about the wine-patches mailing list