module=`basename $BKD_ROOT | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'`
log=`bk changes -r"$REV" -d":C:" | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'`
tag=`bk changes -r"$REV" -d":TAG:" | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'`
-files=`bk changes -n -v -r"$REV" -d"\\\$unless(:GFILE:=ChangeSet){:GFILE:}" | sort -u | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'`
+for file in `bk changes -n -v -r"$REV" -d"\\\$unless(:GFILE:=ChangeSet){:GFILE:}" | sort -u | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'`; do
+ files="$files<file>$file</file>"
+done
# Send an email with the final XML message
(cat <<EOF
<source>
<project>$project_name</project>
<module>$module</module>
-EOF
-
-if test -n "$tag"; then
- echo " <branch>$tag</branch>"
-fi
-
-cat <<EOF
+ <branch>$tag</branch>
</source>
<body>
<commit>
<revision>$REV</revision>
<author>$author</author>
-EOF
-
-if test -n "$files"; then
- echo " <files>"
- for f in $files; do
- echo " <file>$f</file>"
- done
- echo " </files>"
-fi
-
-cat <<EOF
+ <files>$files</files>
<log>$log</log>
</commit>
</body>