make output a bit nicer and fix a typo
[themes.git] / origdiff
1 #!/bin/sh
2
3 RUN_DIR=$(pwd)
4 cd $(dirname "$0")
5 SCRIPT_DIR=$(pwd)
6
7 REPO_LIST="COMM MOZ MOZB DOMI CZ"
8
9 if [ -n "$1" ]; then
10   SRC_DATE="$1"
11   DST_DATE=`TZ=America/Los_Angeles date +%Y-%m-%d`
12
13   HG_COMM_DIR=/mnt/mozilla/hg/comm-central
14   COMM_HG_OPTIONS=
15   COMM_DIR=suite/themes/classic/
16   COMM_LOG=$RUN_DIR/themelog-suitedefault.$SRC_DATE.$DST_DATE.log
17
18   HG_MOZ_DIR=/mnt/mozilla/hg/comm-central/mozilla
19   MOZ_HG_OPTIONS=
20   MOZ_DIR=toolkit/themes/winstripe/
21   MOZ_LOG=$RUN_DIR/themelog-tkwinstripe.$SRC_DATE.$DST_DATE.log
22
23   HG_MOZB_DIR=/mnt/mozilla/hg/comm-central/mozilla
24   MOZB_HG_OPTIONS=
25   MOZB_DIR=browser/themes/winstripe/
26   MOZB_LOG=$RUN_DIR/themelog-browserwin.$SRC_DATE.$DST_DATE.log
27
28   HG_DOMI_DIR=/mnt/mozilla/hg/comm-central/mozilla/extensions/inspector
29   DOMI_HG_OPTIONS=
30   DOMI_DIR=resources/skin/classic/
31   DOMI_LOG=$RUN_DIR/themelog-domiclassic.$SRC_DATE.$DST_DATE.log
32
33   HG_CZ_DIR=/mnt/mozilla/hg/comm-central/mozilla/extensions/irc
34   CZ_HG_OPTIONS=
35   CZ_DIR=xul/skin/
36   CZ_LOG=$RUN_DIR/themelog-chatzilla.$SRC_DATE.$DST_DATE.log
37
38   for repo in $REPO_LIST; do
39     HG_DIR_VAR="HG_${repo}_DIR"
40     HG_DIR=${!HG_DIR_VAR}
41     HG_OPTIONS_VAR="${repo}_HG_OPTIONS"
42     HG_OPTIONS=${!HG_OPTIONS_VAR}
43     SKIN_DIR_VAR="${repo}_DIR"
44     SKIN_DIR=${!SKIN_DIR_VAR}
45     LOG_VAR="${repo}_LOG"
46     LOG_NAME=${!LOG_VAR}
47     if [ ! -e $LOG_NAME ]; then
48       echo "Getting $LOG_NAME..."
49       cd $HG_DIR
50       LC_ALL=C hg log -d ">$SRC_DATE" $HG_OPTIONS $SKIN_DIR > $LOG_NAME
51     fi
52   done
53   cd $RUN_DIR
54 else
55   echo "You must specify a start date."
56   exit 1
57 fi
58
59 for repo in $REPO_LIST; do
60   HG_DIR_VAR="HG_${repo}_DIR"
61   LOG_VAR="${repo}_LOG"
62   HG_URL=`awk -F ' *= *' '/default *=/ { print $2 }' ${!HG_DIR_VAR}/.hg/hgrc`
63   REPO_NAME=`basename $HG_URL`
64   LOG_NAME=${!LOG_VAR}
65   HTML_NAME=${LOG_NAME/.log/.html}
66   echo "Writing $HTML_NAME..."
67   echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' > $HTML_NAME
68   echo "<html>" >> $HTML_NAME
69   echo "  <head>" >> $HTML_NAME
70   echo "    <title>$REPO_NAME Theme Changes</title>" >> $HTML_NAME
71   echo "  </head>" >> $HTML_NAME
72   echo "  <body>" >> $HTML_NAME
73   echo "  <h1>$REPO_NAME Theme Changes</h1>" >> $HTML_NAME
74   echo "  <h2>$SRC_DATE to $DST_DATE</h2>" >> $HTML_NAME
75   echo "    <pre>" >> $HTML_NAME
76   sed -e "s/&/\&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" \
77       -e "s|\(changeset: *[0-9]*\):\([0-9a-f]*\)|\1:<a href=\"$HG_URL/rev/\2\">\2</a>|" \
78       $LOG_NAME >> $HTML_NAME
79   echo "    </pre>" >> $HTML_NAME
80   echo "  </body>" >> $HTML_NAME
81   echo "</html>" >> $HTML_NAME
82 done
83
84 echo "done."