Index: /other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh
===================================================================
--- /other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh	(revision 28068)
+++ /other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh	(revision 28069)
@@ -72,4 +72,12 @@
 # http://stackoverflow.com/questions/1301203/removing-svn-files-from-all-directories
 
+#*******************************GLOBAL VARIABLES***************************
+
+# mode can be svndelete or svnupdate
+mode=
+debug_mode=0
+commit_message=
+
+#*****************************FUNCTIONS*****************************
 
 # DON'T ADD ANY FURTHER ECHO STATEMENTS IN FUNCTION get_col_basename
@@ -113,11 +121,23 @@
     fi
 
-    # commit all the svn rm statements done above in one go:
-    # don't do `svn up` here, as this will then retrieve all the folders that were svn-removed
-    svn commit -m "AUTOCOMMIT by gen-model-colls.sh script. Clean rebuild of model collections 1/2. Clearing out deprecated archives and index." model-collect
-
-    # do an svn up to locally delete what was svn-removed above, BEFORE copying from the rebuilt archives and index folders
-    svn up model-collect
-
+    # svn commit all the svn rm statements done above in one go:
+    # don't do `svn up` at this point, as doing so will then retrieve all the folders that just were svn-removed
+
+    if [ "x$commit_message" == "x" ]; then
+	commit_message="Clean rebuild of model collections 1/2. Clearing out deprecated archives and index."
+    fi
+
+    # Numerical comparisons: http://tldp.org/LDP/abs/html/comparison-ops.html
+    if [ "$debug_mode" -eq "0" ]; then
+	svn commit -m "AUTOCOMMIT by gen-model-colls.sh script. Message: $commit_message" model-collect
+    fi
+
+    # Having svn committed the deletes, do an svn up to locally delete what was svn-removed above, 
+    # BEFORE copying from the rebuilt archives and index folders
+    if [ "$debug_mode" -eq "0" ]; then
+	svn up model-collect	
+    fi
+
+    # copy from the rebuilt archives and index over into the svn model-collect and svn add them
     if [ "x$1" == "x" ]; then
 	for collection in collect/*; do	    
@@ -131,5 +151,11 @@
 
     # commit all the svn add statements done just above in one go
-    svn commit -m "AUTOCOMMIT by gen-model-colls.sh script. Clean rebuild of model collections 2/2. Adding rebuilt archives and index." model-collect
+    if [ "x$commit_message" == "x" ]; then
+	commit_message="Clean rebuild of model collections 2/2. Adding rebuilt archives and index."
+    fi
+
+    if [ "$debug_mode" -eq "0" ]; then
+	svn commit -m "AUTOCOMMIT by gen-model-colls.sh script. Message: $commit_message" model-collect
+    fi
 
     echo
@@ -159,10 +185,11 @@
 
     # remove the entire archives and index folders from svn
-    svn rm model-collect/$collection/archives
-    svn rm model-collect/$collection/index
-
-# for TESTING purposes:
-#    rm -rf model-collect/$collection/archives
-#    rm -rf model-collect/$collection/index
+    if [ "$debug_mode" -eq "0" ]; then
+	svn rm model-collect/$collection/archives
+	svn rm model-collect/$collection/index
+    elif [ "$debug_mode" -eq "1" ]; then
+	rm -rf model-collect/$collection/archives
+	rm -rf model-collect/$collection/index
+    fi
 
 }
@@ -184,7 +211,9 @@
     cp -r collect/$collection/archives model-collect/$collection/.
     cp -r collect/$collection/index model-collect/$collection/.	
-    
-    svn add model-collect/$collection/archives
-    svn add model-collect/$collection/index
+
+    if [ "$debug_mode" -eq "0" ]; then
+	svn add model-collect/$collection/archives
+	svn add model-collect/$collection/index
+    fi
 }
 
@@ -252,4 +281,11 @@
     cp -r collect/$collection/index/* model-collect/$collection/index/.
 
+    # now svn add any and all the NEW items in model-collect's archives and index
+    # see http://stackoverflow.com/questions/1071857/how-do-i-svn-add-all-unversioned-files-to-svn
+#    if [ "$debug_mode" -eq "0" ]; then
+	svn add --force model-collect/$collection/archives/* --auto-props --parents --depth infinity -q
+	svn add --force model-collect/$collection/index/* --auto-props --parents --depth infinity -q
+#    fi
+
     echo "svn model-collect update process complete. CHECK AND COMMIT THE model-collect FOLDER!"
 
@@ -296,10 +332,10 @@
 
 
-# The program starts here
+#*******************************MAIN PROGRAM***************************
 
 # process optional command line arguments
 # http://blog.onetechnical.com/2012/07/16/bash-getopt-versus-getopts/
 # Execute getopt
-ARGS=$(getopt -o ud -l "svnupdate,svndelete" -n "$0" -- "$@");
+ARGS=$(getopt -o m:uxd -l "message:,svnupdate,svndelete,debug" -n "$0" -- "$@");
 
 #Bad arguments
@@ -311,11 +347,9 @@
 eval set -- "$ARGS";
 
-# mode can be svndelete or svnupdate
-mode=
 
 # -n: http://tldp.org/LDP/abs/html/testconstructs.html
 while true; do
   case "$1" in
-    -d|--svndelete)
+    -x|--svndelete)
       shift;
       if [ "x$mode" == "xsvnupdate" ]; then
@@ -339,4 +373,15 @@
       fi
       ;;
+    -d|--debug)
+      shift;
+      debug_mode=1
+      ;;
+    -m|--message)
+      shift;
+      if [ -n "$1" ]; then
+	  commit_message=$1
+          shift;
+      fi
+      ;;
     --)
       shift;
@@ -345,4 +390,8 @@
   esac
 done
+
+#echo "commit message: $commit_message"
+#echo "Debug mode is: $debug_mode"
+#exit
 
 # If no mode provided (svndelete|svnupdate) as cmd line arg, then don't modify
@@ -390,9 +439,5 @@
     else
 	for collection in "$@"; do
-	    if [ -e model-collect/$collection ]; then
-		svn up model-collect/$collection
-	    else
-		svn up model-collect
-	    fi
+	    svn up model-collect/$collection
 	done
     fi
@@ -512,6 +557,14 @@
     echo "* DIFFERENCES REMAINING BETWEEN model-collect AND collect (skipping .svn folders):"
     echo
-    echo "---START DIFF---"
-    diff -rq model-collect collect | grep -v ".svn"
+    if [ "$1" == "" ]; then
+	echo "---START DIFF---"
+	diff -rq model-collect collect | grep -v ".svn"
+    else
+	for collection in "$@"; do
+	    echo "--COLLECTION: $collection"
+	    diff -rq model-collect/$collection collect/$collection | grep -v ".svn"
+	    echo "--"
+	done
+    fi
     echo "---END DIFF---"
     echo
@@ -519,4 +572,9 @@
 
 echo "* The original collect directory has been left renamed as collect_orig"
+echo
+
+if [ "$debug_mode" -eq "1" ]; then
+    echo "* This script was run in DEBUG MODE, nothing has been changed in svn"
+fi
 echo
 echo "*****************************************"
