#! /bin/tcsh -f
#
# Find all new files between two dates
# Usage: NewSince.csh StartDate EndDate
#

if ($#argv != 2) then
    echo "Usage: NewSince.csh StartDate EndDate"
    exit (1)
endif

echo "Changes from $1 to $2"

set FROM="$1"
set TO="$2"

set TEMPDIR=@ITK_BINARY_DIR@/Testing/Temporary

(cd @ITK_SOURCE_DIR@; cvs log -d"$FROM<$TO" >${TEMPDIR}/$$.allchanges)

gawk -f @ITK_SOURCE_DIR@/Utilities/Dart/NewSince.gawk ${TEMPDIR}/$$.allchanges | cut -d"/" -f5- >${TEMPDIR}/$$.newandremoved

#
# remove files in the Attic
#
grep -v Attic ${TEMPDIR}/$$.newandremoved >${TEMPDIR}/$$.new

echo "This release covers the period ${FROM} through ${TO}" > ${TEMPDIR}/$$.wikitemp
echo "== New Classes in this Release ==" >> ${TEMPDIR}/$$.wikitemp
echo "<pre>" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/Algorithms" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/BasicFilters" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/Common" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/IO" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/Numerics/itk" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/Numerics/NeuralNetworks" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/Numerics/Statistics" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/SpatialObject" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Code/Patented" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "</pre>" >> ${TEMPDIR}/$$.wikitemp

echo "== New Tests in this Release =="  >> ${TEMPDIR}/$$.wikitemp
echo "<pre>" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/Common" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/BasicFilters" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/IO" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/Algorithms" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/Numerics" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/SpatialObject" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Testing/Code/Patented" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "</pre>" >> ${TEMPDIR}/$$.wikitemp

echo "== New Examples in this Release ==" >> ${TEMPDIR}/$$.wikitemp
echo "<pre>" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/DataRepresentation" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Filtering" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/GUI" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Infrastructure" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Installation" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/IO" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Iterators" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Numerics" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Patented" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Registration" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Segmentations" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/SpatialObjects" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Statistics" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Visualization" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "" >> ${TEMPDIR}/$$.wikitemp
grep "^Examples/Wrapping" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "</pre>" >> ${TEMPDIR}/$$.wikitemp

echo "== New Utilities in this Release ==" >> ${TEMPDIR}/$$.wikitemp
echo "<pre>" >> ${TEMPDIR}/$$.wikitemp
grep "^Utilities/" ${TEMPDIR}/$$.new | sort | uniq >> ${TEMPDIR}/$$.wikitemp
echo "</pre>" >> ${TEMPDIR}/$$.wikitemp

#
# remove consecutive blank lines
#
cat -s ${TEMPDIR}/$$.wikitemp > ${TEMPDIR}/NewSince.txt
echo "A Wiki-compatible list of new files is in ${TEMPDIR}/NewSince.txt"
#
# cleanup
#
rm -f ${TEMPDIR}/$$.*
