Index: branches/tap_branches/ippTasks/stack.pro
===================================================================
--- branches/tap_branches/ippTasks/stack.pro	(revision 25900)
+++ branches/tap_branches/ippTasks/stack.pro	(revision 27838)
@@ -14,4 +14,5 @@
 ### Database lists
 $stackSkycell_DB = 0
+$stack_revert_DB = 0
 #$stackCleanup_DB = 0
 
@@ -36,4 +37,7 @@
     active true
   end
+  task stack.revert
+    active false
+  end
 end
 
@@ -46,5 +50,24 @@
     active false
   end
-end
+  task stack.revert
+    active false
+  end
+end
+
+macro stack.revert.on
+  task stack.revert
+    active true
+  end
+end
+
+macro stack.revert.off
+  task stack.revert
+    active false
+  end
+end
+
+
+
+
 
 # macro stack.cleanup.on
@@ -88,10 +111,10 @@
       # save the DB name for the exit tasks
       option $DB:$stackSkycell_DB
-      $run = $run -dbname $DB:$stackSkycell_DB
+      $run = $run -dbname $DB:$stackSkycell_DB -limit 40
       $stackSkycell_DB ++
       if ($stackSkycell_DB >= $DB:n) set stackSkycell_DB = 0
     end
     add_poll_args run
-    add_poll_labels run
+    # add_poll_labels run
     command $run
   end
@@ -124,4 +147,7 @@
 end
 
+
+
+
 ### Run tasks for calculating the stack overlaps
 ### Tasks are taken from stackSumSkyfile.
@@ -135,5 +161,6 @@
     if ($N == 0) break
     if ($NETWORK == 0) break
-    
+    if ($BURNTOOLING == 1) break
+
     # look for new images in stackSumSkyfile (pantaskState == INIT)
     book getpage stackSumSkyfile 0 -var pageName -key pantaskState INIT
@@ -316,2 +343,54 @@
 #   end
 # end
+
+task stack.revert
+  host         local
+
+  periods      -poll 60.0
+  periods      -exec 1800.0
+  periods      -timeout 120.0
+  npending     1
+  active false
+  
+  stdout NULL
+  stderr $LOGDIR/revert.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    # Only revert failures with fault=2 (SYS_ERROR), which tend to be
+    # temporary filesystem problems.  Every other fault type is
+    # interesting and should be kept for debugging (and so it doesn't
+    # continue to occur).
+    $run = stacktool -revertsumskyfile -fault 2
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$stack_revert_DB
+      $run = $run -dbname $DB:$stack_revert_DB
+      $stack_revert_DB ++
+      if ($stack_revert_DB >= $DB:n) set stack_revert_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
+
