Index: /tags/ipp-20101215/ippTools/share/difftool_pendingcleanupskyfile.sql
===================================================================
--- /tags/ipp-20101215/ippTools/share/difftool_pendingcleanupskyfile.sql	(revision 30544)
+++ /tags/ipp-20101215/ippTools/share/difftool_pendingcleanupskyfile.sql	(revision 30545)
@@ -9,5 +9,5 @@
     USING(diff_id)
 WHERE
-   ((diffRun.state = 'goto_cleaned'  AND diffSkyfile.data_state = 'full')
+   ((diffRun.state = 'goto_cleaned'  AND (diffSkyfile.data_state = 'full' OR diffSkyfile.data_state = 'update'))
     OR
     (diffRun.state = 'goto_scrubbed' AND diffSkyfile.data_state != 'scrubbed')
Index: /tags/ipp-20101215/ippTools/share/difftool_setskyfiletoupdate.sql
===================================================================
--- /tags/ipp-20101215/ippTools/share/difftool_setskyfiletoupdate.sql	(revision 30544)
+++ /tags/ipp-20101215/ippTools/share/difftool_setskyfiletoupdate.sql	(revision 30545)
@@ -1,11 +1,9 @@
 UPDATE diffRun
     JOIN diffSkyfile USING(diff_id)
-    LEFT JOIN magicDSRun ON (stage_id = diff_id AND stage = 'diff')
-    LEFT JOIN magicDSFile ON (magicDSRun.magic_ds_id = magicDSFile.magic_ds_id
-                              AND component = skycell_id)
 SET diffRun.state = 'update', 
-    diffSkyfile.data_state = 'update'
+    diffSkyfile.data_state = 'update',
+    diffSkyfile.fault = 0
     -- set hook %s
 WHERE diff_id = %lld
     AND (diffRun.state = 'cleaned' OR diffRun.state = 'update')
-    AND (diffSkyfile.data_state = 'cleaned')
+    AND (diffSkyfile.data_state = 'cleaned' AND diffSkyfile.data_state = 'update')
Index: /tags/ipp-20101215/ippTools/share/magicdstool_setfiletoupdate.sql
===================================================================
--- /tags/ipp-20101215/ippTools/share/magicdstool_setfiletoupdate.sql	(revision 30544)
+++ /tags/ipp-20101215/ippTools/share/magicdstool_setfiletoupdate.sql	(revision 30545)
@@ -7,3 +7,3 @@
 WHERE magic_ds_id = %lld
     AND (magicDSRun.state = 'cleaned' OR magicDSRun.state = 'update')
-    AND (magicDSFile.data_state = 'cleaned')
+    AND (magicDSFile.data_state = 'cleaned' OR magicDSFile.data_state ='update')
Index: /tags/ipp-20101215/ippTools/share/warptool_setskyfiletoupdate.sql
===================================================================
--- /tags/ipp-20101215/ippTools/share/warptool_setskyfiletoupdate.sql	(revision 30544)
+++ /tags/ipp-20101215/ippTools/share/warptool_setskyfiletoupdate.sql	(revision 30545)
@@ -1,11 +1,9 @@
 UPDATE warpRun
     JOIN warpSkyfile USING(warp_id)
-    LEFT JOIN magicDSRun ON (stage_id = warp_id AND stage = 'warp')
-    LEFT JOIN magicDSFile ON (magicDSRun.magic_ds_id = magicDSFile.magic_ds_id
-                              AND component = skycell_id)
 SET warpRun.state = 'update', 
-    warpSkyfile.data_state = 'update'
+    warpSkyfile.data_state = 'update',
+    warpSkyfile.fault = 0
     -- set hook %s
 WHERE warp_id = %lld
     AND (warpRun.state = 'cleaned' OR warpRun.state = 'update')
-    AND (warpSkyfile.data_state = 'cleaned')
+    AND (warpSkyfile.data_state = 'cleaned' OR warpSkyfile.data_state = 'update')
Index: /tags/ipp-20101215/ippTools/src/chiptool.c
===================================================================
--- /tags/ipp-20101215/ippTools/src/chiptool.c	(revision 30544)
+++ /tags/ipp-20101215/ippTools/src/chiptool.c	(revision 30545)
@@ -838,4 +838,6 @@
     PXOPT_COPY_S16(config->args, where, "-fault", "chipProcessedImfile.fault", "==");
 
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
     if (!psListLength(where->list)
         && !psMetadataLookupBool(NULL, config->args, "-all")) {
@@ -874,4 +876,11 @@
     }
     psFree(query);
+
+    if (!fault) {
+        // If fault has not been supplied, don't revert update faults with the magic value
+        // We don't do this for new runs because then they would never complete
+        // quality should be used to drop bad components
+        psStringAppend(&query_update, " AND (chipProcessedImfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
+    }
     if (!p_psDBRunQuery(config->dbh, query_update)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -1919,4 +1928,7 @@
     }
 
+    // we do not update components with the magic fault value. They are non-updateable
+    psStringAppend(&query, " AND (chipProcessedImfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
+
     if (!p_psDBRunQueryF(config->dbh, query, setHook, chip_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
Index: /tags/ipp-20101215/ippTools/src/difftool.c
===================================================================
--- /tags/ipp-20101215/ippTools/src/difftool.c	(revision 30544)
+++ /tags/ipp-20101215/ippTools/src/difftool.c	(revision 30545)
@@ -917,4 +917,6 @@
     PXOPT_COPY_S16(config->args, where, "-fault",     "fault", "==");
 
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
     if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
         psFree(where);
@@ -950,4 +952,10 @@
         psLogMsg("difftool", PS_LOG_INFO, "Deleted %" PRIu64 " rows", psDBAffectedRows(config->dbh));
 
+        if (!fault) {
+            // If fault has not been supplied, don't revert update faults with the magic value
+            // We don't do this for new runs because then they would never complete
+            // quality should be used to drop bad components
+            psStringAppend(&query_updated, " AND (diffSkyfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
+        }
         if (!p_psDBRunQuery(config->dbh, query_updated)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -3201,4 +3209,7 @@
         psStringAppend(&query, " AND (diffSkyfile.skycell_id = '%s')", skycell_id);
     }
+    // we do not update components with the magic fault value. They are non-updateable
+    // (But can be recovered with "difftool -revertwarped -fault 26" (PXTOOL_DO_NOT_REVERT_FAULT)
+    psStringAppend(&query, " AND (diffSkyfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
 
     if (!p_psDBRunQueryF(config->dbh, query, setHook, diff_id)) {
Index: /tags/ipp-20101215/ippTools/src/magicdstool.c
===================================================================
--- /tags/ipp-20101215/ippTools/src/magicdstool.c	(revision 30544)
+++ /tags/ipp-20101215/ippTools/src/magicdstool.c	(revision 30545)
@@ -1112,6 +1112,8 @@
 
     PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     psString queryFile = NULL;
+    bool stateIsUpdate = false;
     if (state) {
         if (! strcmp(state, "new") || !strcmp(state, "goto_restored")) {
@@ -1119,4 +1121,5 @@
         } else if (!strcmp(state, "update")) {
             queryFile = "magicdstool_revertupdated.sql";
+            stateIsUpdate = true;
         } else {
             psError(PXTOOLS_ERR_SYS, true, "%s is not a valid value for state", state);
@@ -1141,4 +1144,12 @@
     }
     psFree(where);
+
+    if (stateIsUpdate && !fault) {
+        // If fault has not been supplied, don't revert update faults with
+        // the magic "do not update" value
+        // We don't do this for new runs because then they would never complete
+        // quality should be used to drop bad components
+        psStringAppend(&query, " AND magicDSFile.fault != %d", PXTOOL_DO_NOT_REVERT_FAULT);
+    }
 
     if (!p_psDBRunQuery(config->dbh, query)) {
@@ -1744,4 +1755,8 @@
     }
 
+    // we do not update components with the magic fault value. They are non-updateable
+    // (But can be recovered with "magicdstool -revertdestreakedfile -fault 26" (PXTOOL_DO_NOT_REVERT_FAULT)
+    psStringAppend(&query, " AND (fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
+
     if (!p_psDBRunQueryF(config->dbh, query, setHook, magic_ds_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
Index: /tags/ipp-20101215/ippTools/src/pxtools.h
===================================================================
--- /tags/ipp-20101215/ippTools/src/pxtools.h	(revision 30544)
+++ /tags/ipp-20101215/ippTools/src/pxtools.h	(revision 30545)
@@ -51,4 +51,7 @@
 # define MAX_ROWS 10e9
 # define PXTOOL_MODE_NONE 0x0
+// we do not revert or update components with this fault value
+// This is the same value as PSTAMP_GONE
+# define PXTOOL_DO_NOT_REVERT_FAULT 26
 
 bool pxIsValidState(const char *state);
Index: /tags/ipp-20101215/ippTools/src/warptool.c
===================================================================
--- /tags/ipp-20101215/ippTools/src/warptool.c	(revision 30544)
+++ /tags/ipp-20101215/ippTools/src/warptool.c	(revision 30545)
@@ -1485,4 +1485,6 @@
     PXOPT_COPY_S16(config->args, where, "-fault",      "warpSkyfile.fault", "==");
 
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
     if (!psListLength(where->list)
         && !psMetadataLookupBool(NULL, config->args, "-all")) {
@@ -1510,4 +1512,11 @@
     }
     psFree(where);
+
+    if (!fault) {
+        // If fault has not been supplied, don't revert update faults with the magic value
+        // We don't do this for new runs because then they would never complete
+        // quality should be used to drop bad components
+        psStringAppend(&query_updated, " AND fault != %d", PXTOOL_DO_NOT_REVERT_FAULT);
+    }
 
     if (!p_psDBRunQuery(config->dbh, query)) {
@@ -2003,5 +2012,5 @@
 // shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
 
-static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
+static bool change_skyfile_data_state(pxConfig *config, psString data_state)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -2065,17 +2074,17 @@
 static bool tocleanedskyfileMode(pxConfig *config)
 {
-    return change_skyfile_data_state(config, "cleaned", "goto_cleaned");
+    return change_skyfile_data_state(config, "cleaned");
 }
 static bool tofullskyfileMode(pxConfig *config)
 {
-    return change_skyfile_data_state(config, "full", "update");
+    return change_skyfile_data_state(config, "full");
 }
 static bool topurgedskyfileMode(pxConfig *config)
 {
-    return change_skyfile_data_state(config, "purged", "goto_purged");
+    return change_skyfile_data_state(config, "purged");
 }
 static bool toscrubbedskyfileMode(pxConfig *config)
 {
-     return change_skyfile_data_state(config, "scrubbed", "goto_scrubbed");
+     return change_skyfile_data_state(config, "scrubbed");
 }
 
@@ -2101,11 +2110,11 @@
     else {
       if (strcmp(state,"error_cleaned") == 0) {
-        change_skyfile_data_state(config,"error_cleaned","goto_cleaned");
+        change_skyfile_data_state(config,"error_cleaned");
       }
       else if (strcmp(state, "error_scrubbed") == 0) {
-        change_skyfile_data_state(config,"error_scrubbed","goto_scrubbed");
+        change_skyfile_data_state(config,"error_scrubbed");
       }
       else if (strcmp(state, "error_purged") == 0) {
-        change_skyfile_data_state(config,"error_purged","goto_purged");
+        change_skyfile_data_state(config,"error_purged");
       }
       else {
@@ -2526,4 +2535,7 @@
         psStringAppend(&query, " AND (warpSkyfile.skycell_id = '%s')", skycell_id);
     }
+    // we do not update components with the magic fault value. They are non-updateable
+    // (But can be recovered with "warptool -revertwarped -fault 26" (PXTOOL_DO_NOT_REVERT_FAULT)
+    psStringAppend(&query, " AND (warpSkyfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
 
     if (!p_psDBRunQueryF(config->dbh, query, setHook, warp_id)) {
