Index: trunk/ippTasks/detrend.resid.pro
===================================================================
--- trunk/ippTasks/detrend.resid.pro	(revision 23480)
+++ trunk/ippTasks/detrend.resid.pro	(revision 28557)
@@ -49,7 +49,27 @@
 end
 
+macro detresid.revert.on
+  task detrend.resid.revert
+    active true
+  end
+  task detrend.residexp.revert
+    active true
+  end
+end
+
+macro detresid.revert.off
+  task detrend.resid.revert
+    active false
+  end
+  task detrend.residexp.revert
+    active false
+  end
+end
+
 # these variables will cycle through the known database names
 $detPendingResidImfile_DB = 0
 $detPendingResidExp_DB = 0
+$detPendingResidImfile_revert_DB = 0
+$detPendingResidExp_revert_DB = 0
 
 # select images ready for copy 
@@ -316,2 +336,95 @@
   end
 end
+
+task detrend.resid.revert
+  host         local
+
+  periods      -poll 60.0
+  periods      -exec 1800.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/revert.log
+
+  task.exec
+
+    $run = dettool -revertresidimfile -all 
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$detPendingResidImfile_revert_DB
+      $run = $run -dbname $DB:$detPendingResidImfile_revert_DB
+      $detPendingResidImfile_revert_DB ++
+      if ($detPendingResidImfile_revert_DB >= $DB:n) set detPendingResidImfile_revert_DB = 0
+    end
+    echo $run
+    command $run
+  end
+
+  # success
+  task.exit    0
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+task detrend.residexp.revert
+  host         local
+
+  periods      -poll 60.0
+  periods      -exec 1800.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/revert.log
+
+  task.exec
+  
+
+    $run = dettool -revertresidexp -all 
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$detPendingResidExp_revert_DB
+      $run = $run -dbname $DB:$detPendingResidExp_revert_DB
+      $detPendingResidExp_revert_DB ++
+      if ($detPendingResidExp_revert_DB >= $DB:n) set detPendingResidExp_revert_DB = 0
+    end
+    echo $run
+    command $run
+  end
+
+  # success
+  task.exit    0
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
