webrev wrapper for mq users

Max (Weijun) Wang Weijun.Wang at Sun.COM
Wed Apr 15 04:44:08 PDT 2009


#! /bin/bash
#
# Usage: qr patch_name
#
# Run this script inside a hg repo with mq. It will create a webrev for
# the specified patch (or the tip) and sync it to cr.openjdk.java.net

[ "$1" == "--help" ] && { echo Usage: qr [patch]; exit 0; }

[ "$1" != "" ] && hg qgoto $1

BUGID=`hg tip --template {desc} | head -n1 | cut -c 1-7`
AUTHOR=`hg tip --template {author}`
LASTVER=`wget -q -O - http://cr.openjdk.java.net/~$AUTHOR/$BUGID |  
perl -e '
         $m = -1;
         while (<STDIN>) {
             if (/webrev\.(\d\d)/) {
                 if ($1 > $m) {
                     $m = $1;
                 }
             }
         };
         print $m;
     '`

VER=`perl -e 'printf "%02d", '$LASTVER'+1'`

mkdir -p $BUGID
if [ $LASTVER != "-1" ]; then
     mkdir $BUGID/webrev.$LASTVER
     wget -q -O $BUGID/webrev.$LASTVER/index.html http://cr.openjdk.java.net/~$AUTHOR/$BUGID/webrev.$LASTVER/index.html
     perl -p -i -e 's/<\/head>/<\/head><h3><a href="..\/ 
webrev.'$VER'">A newer webrev<\/a> is available<\/h3><hr\/>/' $BUGID/ 
webrev.$LASTVER/index.html
fi

webrev -O -N -r -2
hg tip > $BUGID/.description
hg tip --template {desc} | head -n1 > $BUGID/.title
mv webrev $BUGID/webrev.$VER
mv webrev.zip $BUGID/webrev.$VER.zip

echo http://cr.openjdk.java.net/~$AUTHOR/$BUGID/webrev.$VER
echo Press Ctrl-C to stop. Enter to continue
read

rsync -avz $BUGID cr.openjdk.java.net:

echo http://cr.openjdk.java.net/~$AUTHOR/$BUGID/webrev.$VER
rm -rf $BUGID




More information about the web-discuss mailing list