diff mbox series

[OSSTEST,2/9] cs-adjust-flight: Break out copy_jobs_*

Message ID 20190502174238.23848-3-ian.jackson@eu.citrix.com (mailing list archive)
State Superseded
Headers show
Series mg-repro-flight: Provide --rebuild to make variant build jobs too | expand

Commit Message

Ian Jackson May 2, 2019, 5:42 p.m. UTC
No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 cs-adjust-flight | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/cs-adjust-flight b/cs-adjust-flight
index ee1d917c..badabeff 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -194,10 +194,8 @@  sub do_rm_job ($) {
     verbose "$dstflight.$job job deleted\n" if $count;
 }
 
-sub copy_jobs ($$) {
-    my ($srcflight, $jobs) = @_;
-    prep_rm_jobs();
-    my @job_copy_qs = map { $dbh_tests->prepare($_) }
+sub copy_jobs_qs () {
+    map { $dbh_tests->prepare($_) }
         ("INSERT INTO jobs (flight, job, recipe, status)".
          "     SELECT ?, job, recipe, 'queued'".
          "       FROM jobs".
@@ -206,12 +204,22 @@  sub copy_jobs ($$) {
          "     SELECT ?, job, name, val, 'f'".
          "       FROM runvars".
          "      WHERE flight = ? AND job = ? AND NOT synth");
+}
+sub copy_jobs_do ($$) {
+    my ($qs, $srcflight, $srcjob) = @_;
+    $_->execute($dstflight, $srcflight, $job) foreach @$qs;
+    verbose "$dstflight.$job job created from $srcflight.$job\n";
+}
+
+sub copy_jobs ($$) {
+    my ($srcflight, $jobs) = @_;
+    prep_rm_jobs();
+    my @job_copy_qs = copy_jobs_qs;
     for_jobs($dstflight, $jobs, \&do_rm_job, 1);
     for_jobs($srcflight, $jobs, \&do_rm_job);
     for_jobs($srcflight, $jobs, sub {
         my ($job) = @_;
-        $_->execute($dstflight, $srcflight, $job) foreach @job_copy_qs;
-	verbose "$dstflight.$job job created from $srcflight.$job\n";
+	copy_jobs_do(\@job_copy_qs, $srcflight, $job);
     });
 }