+let copy_prev_state old t =
+ let is_explicit jobname =
+ String.length jobname < 4 || String.sub jobname 0 4 <> "job$"
+ in
+
+ let prev_variables = StringMap.fold (
+ fun jobname _ map ->
+ try
+ if not (is_explicit jobname) then raise Not_found;
+ (* See if we can find a job with the same name in the old state. *)
+ let old_vars = StringMap.find jobname old.prev_variables in
+ StringMap.add jobname old_vars map
+ with
+ Not_found -> map
+ ) t.jobmap t.prev_variables in
+
+ let prev_eval_result = StringMap.fold (
+ fun jobname _ map ->
+ try
+ if not (is_explicit jobname) then raise Not_found;
+ (* See if we can find a job with the same name in the old state. *)
+ let old_result = StringMap.find jobname old.prev_eval_result in
+ StringMap.add jobname old_result map
+ with
+ Not_found -> map
+ ) t.jobmap t.prev_eval_result in
+
+ { t with
+ prev_variables = prev_variables; prev_eval_result = prev_eval_result }
+