Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 13691)
+++ trunk/ippTools/src/difftool.c	(revision 14108)
@@ -38,4 +38,5 @@
 static bool adddiffskyfileMode(pxConfig *config);
 static bool diffskyfileMode(pxConfig *config);
+static bool revertdiffskyfileMode(pxConfig *config);
 
 static bool setdiffRunState(pxConfig *config, const char *warp_id, const char *state);
@@ -66,4 +67,5 @@
         MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE,     adddiffskyfileMode);
         MODECASE(DIFFTOOL_MODE_DIFFSKYFILE,        diffskyfileMode);
+        MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE,  revertdiffskyfileMode);
         default:
             psAbort("invalid option (this should not happen)");
@@ -521,4 +523,11 @@
     }
 
+    // default values
+    psS16 code = psMetadataLookupS16(&status, config->args, "-code");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
+        return false;
+    }
+
     if (!psDBTransaction(config->dbh)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -531,5 +540,6 @@
             path_base,
             bg,
-            bg_stdev
+            bg_stdev,
+            code
         )) {
         if (!psDBRollback(config->dbh)) {
@@ -645,4 +655,37 @@
 }
 
+
+static bool revertdiffskyfileMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    psString query = pxDataGet("difftool_revertdiffskyfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
+
+    if (config->where) {
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
+        psStringAppend(&query, " AND %s", whereClause);
+        psFree(whereClause);
+    }
+
+    if (!p_psDBRunQuery(config->dbh, query)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(query);
+        return false;
+    }
+    psFree(query);
+
+    if (psDBAffectedRows(config->dbh) < 1) {
+        psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
+        return false;
+    }
+
+    return true;
+}
+
+
 static bool setdiffRunState(pxConfig *config, const char *diff_id, const char *state)
 {
