Index: /trunk/ippTools/src/warptool.c
===================================================================
--- /trunk/ippTools/src/warptool.c	(revision 11730)
+++ /trunk/ippTools/src/warptool.c	(revision 11731)
@@ -32,4 +32,5 @@
 
 static bool definerunMode(pxConfig *config);
+static bool updaterunMode(pxConfig *config);
 static bool addinputexpMode(pxConfig *config);
 static bool toscfileMode(pxConfig *config);
@@ -43,4 +44,7 @@
 static bool diffimfileMode(pxConfig *config);
 
+static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state);
+static bool isValidMode(pxConfig *config, const char *mode);
+
 # define MODECASE(caseName, func) \
     case caseName: \
@@ -58,4 +62,5 @@
     switch (config->mode) {
         MODECASE(P4TOOL_MODE_DEFINERUN,         definerunMode);
+        MODECASE(P4TOOL_MODE_UPDATERUN,         updaterunMode);
         MODECASE(P4TOOL_MODE_ADDINPUTEXP,       addinputexpMode);
         MODECASE(P4TOOL_MODE_TOSCFILE,          toscfileMode);
@@ -88,4 +93,5 @@
 }
 
+
 static bool definerunMode(pxConfig *config)
 {
@@ -101,4 +107,9 @@
     if (!mode) {
         psError(PS_ERR_UNKNOWN, true, "-mode is required");
+        return false;
+    }
+    // check mode
+    if (mode && !isValidMode(config, mode)) {
+        psError(PS_ERR_UNKNOWN, false, "invalud mode");
         return false;
     }
@@ -168,4 +179,39 @@
     return true;
 }
+
+
+static bool updaterunMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    bool status = false;
+    psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4t_id");
+        return false;
+    }
+    if (!p4_id) {
+        psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
+        return false;
+    }
+
+    psString state = psMetadataLookupStr(&status, config->args, "-state");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
+        return false;
+    }
+    if (!state) {
+        psError(PS_ERR_UNKNOWN, true, "-state is required");
+        return false;
+    }
+
+    if (state) {
+        // set detRun.state to state
+        return setp4RunState(config, p4_id, state);
+    }
+
+    return true;
+}
+
 
 static bool addinputexpMode(pxConfig *config)
@@ -857,2 +903,48 @@
     return true;
 }
+
+static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state)
+{
+    PS_ASSERT_PTR_NON_NULL(p4_id, false);
+    PS_ASSERT_PTR_NON_NULL(state, false);
+
+    // check that state is a valid string value
+    if (!(
+            (strncmp(state, "run", 4) == 0)
+            || (strncmp(state, "stop", 5) == 0)
+            || (strncmp(state, "reg", 4) == 0)
+        )
+    ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "invalid p4Run state: %s", state);
+        return false;
+    }
+
+    char *query = "UPDATE p4Run SET state = '%s' WHERE det_id = '%s'";
+    if (!p_psDBRunQuery(config->dbh, query, state, p4_id)) {
+        psError(PS_ERR_UNKNOWN, false,
+                "failed to change state for det_id %s", p4_id);
+        return false;
+    }
+
+    return true;
+}
+
+static bool isValidMode(pxConfig *config, const char *mode)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+    PS_ASSERT_PTR_NON_NULL(mode, false);
+
+    // check that state is a valid string value
+    if (!(
+            (strncmp(mode, "master", 7) == 0)
+            || (strncmp(mode, "verify", 7) == 0)
+        )
+    ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "invalid detRun mode: %s", mode);
+        return false;
+    }
+
+    return true;
+}
Index: /trunk/ippTools/src/warptool.h
===================================================================
--- /trunk/ippTools/src/warptool.h	(revision 11730)
+++ /trunk/ippTools/src/warptool.h	(revision 11731)
@@ -26,4 +26,5 @@
     P4TOOL_MODE_NONE           = 0x0,
     P4TOOL_MODE_DEFINERUN,
+    P4TOOL_MODE_UPDATERUN,
     P4TOOL_MODE_ADDINPUTEXP,
     P4TOOL_MODE_TOSCFILE,
Index: /trunk/ippTools/src/warptoolConfig.c
===================================================================
--- /trunk/ippTools/src/warptoolConfig.c	(revision 11730)
+++ /trunk/ippTools/src/warptoolConfig.c	(revision 11731)
@@ -56,4 +56,17 @@
     psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple",  0,
             "use the simple output format", false);
+ 
+    // -updaterun
+    psMetadata *updaterunArgs = psMetadataAlloc();
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "define p4 ID (required)", NULL);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0,
+            "set state (required)", NULL);
+#if 0
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-workdir", 0,
+            "define workdir (required)", NULL);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-registered",  0,
+            "time detrend run was registered", now);
+#endif
 
     // -addinputexp
@@ -194,4 +207,5 @@
     // find which mode we're running under
     PXTOOL_MODE("-definerun",       P4TOOL_MODE_DEFINERUN,      definerunArgs);
+    PXTOOL_MODE("-updaterun",       P4TOOL_MODE_UPDATERUN,      updaterunArgs);
     PXTOOL_MODE("-addinputexp",     P4TOOL_MODE_ADDINPUTEXP,    addinputexpArgs);
     PXTOOL_MODE("-toscfile",        P4TOOL_MODE_TOSCFILE,       toscfileArgs);
