Index: /branches/eam_branches/eam_branch_20090303/ippTools/src/warptool.c
===================================================================
--- /branches/eam_branches/eam_branch_20090303/ippTools/src/warptool.c	(revision 23180)
+++ /branches/eam_branches/eam_branch_20090303/ippTools/src/warptool.c	(revision 23181)
@@ -55,4 +55,5 @@
 static bool updateskyfileMode(pxConfig *config);
 
+static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state);
 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
 static bool isValidMode(pxConfig *config, const char *mode);
@@ -1604,4 +1605,9 @@
 // shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
 
+// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
+// this is getting fairly messy now that we have added a few additional target and
+// destination states.  I'm disabling these restrictions for now; is there are better way
+// to enforce the allowed state transitions?
+
 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
 {
@@ -1619,6 +1625,8 @@
     }
 
+    // XXX this feature is disabled (run_state is ignored)
     // note only updates if warpRun.state = run_state
-    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) {
+
+    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         // rollback
@@ -1668,14 +1676,37 @@
     PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
     PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
+    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
     PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
 
-    psString query = pxDataGet("warptool_updateskyfile.sql");
-
-    if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-    psFree(query);
-
-    return true;
-}
+    if (state && code) {
+        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
+        return false;
+    }
+
+    if (state) {
+      // make sure that the state string is valid
+      if (!pxIsValidState(state)) {
+        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
+        return false;
+      }
+      if (!change_skyfile_data_state(config, state, "unknown")) {
+        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
+        return false;
+      }
+      return true;
+    }
+
+    if (code) {
+      psString query = pxDataGet("warptool_updateskyfile.sql");
+
+      if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+      }
+      psFree(query);
+      return true;
+    }
+
+    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
+    return false;
+}
