Index: trunk/ippTools/share/pubtool_definerun.sql
===================================================================
--- trunk/ippTools/share/pubtool_definerun.sql	(revision 28309)
+++ trunk/ippTools/share/pubtool_definerun.sql	(revision 28319)
@@ -6,5 +6,5 @@
 FROM (
     -- Get diffs to publish
-    SELECT
+    SELECT DISTINCT
         client_id,
         diff_id AS stage_id,
@@ -12,7 +12,13 @@
     FROM publishClient
     JOIN diffRun
+    JOIN diffInputSkyfile USING(diff_id)
+    JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 -- Only JOINing input, not reference!
+    JOIN fakeRun USING(fake_id)
+    JOIN camRun USING(cam_id)
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
     WHERE publishClient.stage = 'diff'
         AND publishClient.active = 1
-        AND diffRun.state = 'full'
+        AND diffRun.state IN ('full', 'cleaned', 'goto_cleaned')
         AND (diffRun.magicked > 0 OR diffRun.diff_mode = 4 OR publishClient.magicked = 0)
     -- WHERE hook %s
@@ -25,7 +31,9 @@
     FROM publishClient
     JOIN camRun
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
     WHERE publishClient.stage = 'camera'
         AND publishClient.active = 1
-        AND camRun.state = 'full'
+        AND camRun.state IN ('full', 'cleaned', 'goto_cleaned')
         AND (camRun.magicked > 0 OR publishClient.magicked = 0)
     -- WHERE hook %s
@@ -33,3 +41,2 @@
 -- Only get stuff that hasn't been published
 LEFT JOIN publishRun USING(client_id, stage_id)
-WHERE publishRun.client_id IS NULL
Index: trunk/ippTools/share/pubtool_pending.sql
===================================================================
--- trunk/ippTools/share/pubtool_pending.sql	(revision 28309)
+++ trunk/ippTools/share/pubtool_pending.sql	(revision 28319)
@@ -26,5 +26,5 @@
         AND publishClient.active = 1
         AND publishRun.state = 'new'
-        AND diffRun.state = 'full'
+        AND diffRun.state IN ('full', 'cleaned', 'goto_cleaned')
         AND (diffRun.magicked > 0 OR diffRun.diff_mode = 4 OR publishClient.magicked = 0)
         -- WHERE hook %s
@@ -47,5 +47,5 @@
         AND publishClient.active = 1
         AND publishRun.state ='new'
-        AND camRun.state = 'full'
+        AND camRun.state IN ('full', 'cleaned', 'goto_cleaned')
         AND (camRun.magicked > 0 OR publishClient.magicked = 0)
         -- WHERE hook %s
Index: trunk/ippTools/src/pubtool.c
===================================================================
--- trunk/ippTools/src/pubtool.c	(revision 28309)
+++ trunk/ippTools/src/pubtool.c	(revision 28319)
@@ -157,5 +157,12 @@
     // optional
     PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "==");
-    pxAddLabelSearchArgs(config, where, "-label", "label", "=="); // define using newExp label
+    pxAddLabelSearchArgs(config, where, "-label", "label", "==");
+    pxAddLabelSearchArgs(config, where, "-data_group", "data_group", "==");
+    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">=");
+    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<=");
+    PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "LIKE");
+    PXOPT_COPY_STR(config->args, where, "-obs_mode", "rawExp.obs_mode", "LIKE");
+
+    PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false);
 
     psString query = pxDataGet("pubtool_definerun.sql"); // Query to run
@@ -164,4 +171,8 @@
         psFree(where);
         return false;
+    }
+
+    if (!rerun) {
+        psStringAppend(&query, "WHERE publishRun.client_id IS NULL");
     }
 
@@ -241,5 +252,5 @@
     PXOPT_COPY_STR(config->args, where, "-stage", "publishClient.stage", "==");
     PXOPT_COPY_STR(config->args, where, "-comment", "publishClient.comment", "LIKE");
-    PXOPT_COPY_STR(config->args, where, "-label", "publishRun.label", "==");
+    pxAddLabelSearchArgs(config, where, "-label", "label", "==");
 
     // optional
Index: trunk/ippTools/src/pubtoolConfig.c
===================================================================
--- trunk/ippTools/src/pubtoolConfig.c	(revision 28309)
+++ trunk/ippTools/src/pubtoolConfig.c	(revision 28319)
@@ -64,4 +64,11 @@
     psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-client_id", 0, "search by client_id", 0);
     psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "set and search by label", NULL);
+    psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-data_group", PS_META_DUPLICATE_OK, "search by data_group", NULL);
+    psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-rerun", 0, "Re-run publish?", false);
+    psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL);
+    psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<=)", NULL);
+    psMetadataAddStr(definerunArgs,  PS_LIST_TAIL, "-filter", 0, "search for filter", NULL);
+    psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-obs_mode", 0, "search by observation mode", NULL);
+
 
     // -pending
@@ -70,5 +77,5 @@
     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-stage", 0, "search on source", NULL);
     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
-    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-label", 0, "search on label", NULL);
+    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search on label", NULL);
     psMetadataAddBool(pendingArgs, PS_LIST_TAIL, "-simple",  0, "use simple output format?", false);
     psMetadataAddU64(pendingArgs, PS_LIST_TAIL, "-limit",  0, "limit result set", 0);
