Index: branches/tap_branches/ippTasks/magic.pro
===================================================================
--- branches/tap_branches/ippTasks/magic.pro	(revision 25900)
+++ branches/tap_branches/ippTasks/magic.pro	(revision 27838)
@@ -14,4 +14,6 @@
 $magicToTree_DB = 0
 $magicToProcess_DB = 0
+$magicRevertTree_DB = 0
+$magicRevertNode_DB = 0
 
 ### Check status of tasks
@@ -28,4 +30,13 @@
 
 ### Turn tasks on
+macro magic.revert.on
+  task magic.revert.node
+    active true
+  end
+  task magic.revert.tree
+    active true
+  end
+end
+
 macro magic.on
   task magic.tree.load
@@ -40,4 +51,14 @@
   task magic.process.run
     active true
+  end
+  magic.revert.on
+end
+
+macro magic.revert.off
+  task magic.revert.node
+    active false
+  end
+  task magic.revert.tree
+    active false
   end
 end
@@ -57,4 +78,5 @@
     active false
   end
+  magic.revert.off
 end
 
@@ -190,6 +212,7 @@
 
   periods      -poll $LOADPOLL
-  periods      -exec $LOADEXEC
-  periods      -timeout 30
+#  periods      -exec $LOADEXEC
+  periods      -exec 30
+  periods      -timeout 300
   npending     1
 
@@ -283,10 +306,7 @@
     $WORKDIR = $WORKDIR_TEMPLATE
 
-    sprintf outroot "%s/%s/%s.mgc.%s.%s" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID $NODE
-
-    ## generate output log based on filerule (convert the URI to a PATH)
-    ## caution with neb:// names here:
-    # $logfile = `ipp_filename.pl --filerule LOG.EXP --camera $CAMERA --class_id $MAGIC_ID --basename $outroot`
-    $logfile = $outroot.log
+    sprintf baseroot "%s/%s/%s.mgc.%s" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID
+
+    $logfile = $baseroot.$NODE.log
     if ("$logfile" == "") 
       echo "WARNING: logfile not defined in magic.process.run"
@@ -299,5 +319,5 @@
     mkdir $outpath
 
-    $run = magic_process.pl --magic_id $MAGIC_ID --camera $CAMERA --node $NODE --outroot $outroot --logfile $logfile
+    $run = magic_process.pl --magic_id $MAGIC_ID --camera $CAMERA --node $NODE --baseroot $baseroot --logfile $logfile
     add_standard_args run
 
@@ -328,2 +348,93 @@
   end
 end
+
+task magic.revert.node
+  host         local
+
+  periods      -poll 60.0
+  periods      -exec 1800.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/revertnode.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = magictool -revertnode
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magicRevertNode_DB
+      $run = $run -dbname $DB:$magicRevertNode_DB
+      $magicRevertNode_DB ++
+      if ($magicRevertNode_DB >= $DB:n) set magicRevertNode_DB = 0
+    end
+    add_poll_labels 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 magic.revert.tree
+  host         local
+
+  periods      -poll 60.0
+  periods      -exec 1800.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/reverttree.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = magictool -reverttree
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magicRevertTree_DB
+      $run = $run -dbname $DB:$magicRevertTree_DB
+      $magicRevertTree_DB ++
+      if ($magicRevertTree_DB >= $DB:n) set magicRevertTree_DB = 0
+    end
+    add_poll_labels 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
