Index: trunk/tools/rundiffskycell.pl
===================================================================
--- trunk/tools/rundiffskycell.pl	(revision 29141)
+++ trunk/tools/rundiffskycell.pl	(revision 29159)
@@ -41,9 +41,12 @@
     if !$diff_id or !$skycell_id;
 
+# if we're asked to update redirect the output
+$redirect = 1 if $update;
+
 my $ipprc =  PS::IPP::Config->new();
 my $dbh = getDBHandle();
 
 # find warp warp diffs that have a cleaned magicDSRun
-my $query1 = "SELECT path_base, diff_skyfile_id,bothways,reduction,diff_mode FROM diffRun JOIN diffSkyfile USING(diff_id)  JOIN diffInputSkyfile USING(diff_id, skycell_id) WHERE diff_id = $diff_id AND skycell_id = '$skycell_id'";
+my $query1 = "SELECT path_base, diff_skyfile_id,bothways,reduction,diff_mode, diffSkyfile.fault FROM diffRun JOIN diffSkyfile USING(diff_id)  JOIN diffInputSkyfile USING(diff_id, skycell_id) WHERE diff_id = $diff_id AND skycell_id = '$skycell_id'";
 
 my $stmt1 = $dbh->prepare($query1);
@@ -54,4 +57,7 @@
 my $bothways = $results->{bothways};
 my $reduction = $results->{reduction};
+my $fault = $results->{fault};
+
+die "cannot update when skycell is not faulted\n" if $update and !$fault;
 
 die "path_base not found\n" if !$path_base;
@@ -105,2 +111,60 @@
 }
 
+__END__
+
+=pod
+
+=head1 NAME
+
+rundiffskyfile.pl - gather the parameters for and execute diff_skycell.pl
+
+=head1 SYNOPSIS
+    
+    perl rundiffskyfile.pl --diff_id <diff_id> --skycell_id <skycell_id> [--threads <num_threads>] [--update] [--redirect-output] [--pretend] [--dbname <dbname>]
+
+Query the database for the results of a diff skycell and rerun the processing, optionally reverting a faulted
+run.
+
+=over 4
+
+=item * --diff_id <diff_id>
+
+The id of the diffSkyfile run to process.
+
+=item * --skycell_id <skycell_id>
+
+The skycell_id of the diffSkyfile run to process.
+
+=item * --threads <num_threads>
+
+The number of threads to use. Default 1.
+Optional.
+
+
+=item * --update
+
+Revert a faulted skycell before processing. If the skycell is not faulted no processing is done.
+WARNING: insure that the standard science procesing either has diff stage turned off or the
+label of this diffRun ommited from the list of labels otherwise it may attempt to processes this run at the same time.
+Optional.
+
+=item *  --redirect-output
+
+Send the output of the command to the logfile. (This is the default if --update is supplied).
+Optional.
+
+=item * --pretend
+
+Just print the commands that would be executed, but do not run them.
+Optional.
+
+=item * --dbname <dbname>
+
+Name of the IPP databse to query. Default is 'gpc1'.
+Optional.
+
+
+=head1 SEE ALSO
+L<runchipimfile.pl>, L<runcameraexp.pl>, L<rundiffskyfile.pl>
+
+=cut
