diff --git a/make/scripts/webrev.ksh b/make/scripts/webrev.ksh new file mode 100644 index 00000000000..b4ba97bf6a2 --- /dev/null +++ b/make/scripts/webrev.ksh @@ -0,0 +1,3182 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +# Use is subject to license terms. +# +# This script takes a file list and a workspace and builds a set of html files +# suitable for doing a code review of source changes via a web page. +# Documentation is available via 'webrev -h'. +# + +WEBREV_UPDATED=23.18-hg + +HTML=' + +\n' + +FRAMEHTML=' + +\n' + +STDHEAD=' + + + + + + +' + +# +# UDiffs need a slightly different CSS rule for 'new' items (we don't +# want them to be bolded as we do in cdiffs or sdiffs). +# +UDIFFCSS=' + +' + +# +# input_cmd | html_quote | output_cmd +# or +# html_quote filename | output_cmd +# +# Make a piece of source code safe for display in an HTML
block.
+#
+html_quote()
+{
+ sed -e "s/&/\&/g" -e "s/\</g" -e "s/>/\>/g" "$@" | expand
+}
+
+#
+# input_cmd | bug2url | output_cmd
+#
+# Scan for bugids and insert links to the relevent bug database.
+#
+bug2url()
+{
+ sed -e 's|[0-9]\{5,\}|&|g'
+}
+
+#
+# input_cmd | sac2url | output_cmd
+#
+# Scan for ARC cases and insert links to the relevent SAC database.
+# This is slightly complicated because inside the SWAN, SAC cases are
+# grouped by ARC: PSARC/2006/123. But on OpenSolaris.org, they are
+# referenced as 2006/123 (without labelling the ARC).
+#
+sac2url()
+{
+ if [[ -z $Oflag ]]; then
+ sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|\1 \2/\3|g'
+ else
+ sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|\1 \2/\3|g'
+ fi
+}
+
+#
+# strip_unchanged | output_cmd
+#
+# Removes chunks of sdiff documents that have not changed. This makes it
+# easier for a code reviewer to find the bits that have changed.
+#
+# Deleted lines of text are replaced by a horizontal rule. Some
+# identical lines are retained before and after the changed lines to
+# provide some context. The number of these lines is controlled by the
+# variable C in the $AWK script below.
+#
+# The script detects changed lines as any line that has a "\\n\", NR, $0}\n"
+ printf "function changed() "
+ printf "{printf \"%%4d %%s\\n\", NR, $0}\n"
+ printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
+}
+ /^ {next}
+ /^>/ {next}
+ /^---/ {next}
+
+ {
+ split($1, a, /[cad]/) ;
+ if (index($1, "a")) {
+ if (a[1] == 0) {
+ n = split(a[2], r, /,/);
+ if (n == 1)
+ printf "BEGIN\t\t{sp(1)}\n"
+ else
+ printf "BEGIN\t\t{sp(%d)}\n",\
+ (r[2] - r[1]) + 1
+ next
+ }
+
+ printf "NR==%s\t\t{", a[1]
+ n = split(a[2], r, /,/);
+ s = r[1];
+ if (n == 1)
+ printf "bl();printf \"\\n\"; next}\n"
+ else {
+ n = r[2] - r[1]
+ printf "bl();sp(%d);next}\n",\
+ (r[2] - r[1]) + 1
+ }
+ next
+ }
+ if (index($1, "d")) {
+ n = split(a[1], r, /,/);
+ n1 = r[1]
+ n2 = r[2]
+ if (n == 1)
+ printf "NR==%s\t\t{removed(); next}\n" , n1
+ else
+ printf "NR==%s,NR==%s\t{removed(); next}\n" , n1, n2
+ next
+ }
+ if (index($1, "c")) {
+ n = split(a[1], r, /,/);
+ n1 = r[1]
+ n2 = r[2]
+ final = n2
+ d1 = 0
+ if (n == 1)
+ printf "NR==%s\t\t{changed();" , n1
+ else {
+ d1 = n2 - n1
+ printf "NR==%s,NR==%s\t{changed();" , n1, n2
+ }
+ m = split(a[2], r, /,/);
+ n1 = r[1]
+ n2 = r[2]
+ if (m > 1) {
+ d2 = n2 - n1
+ if (d2 > d1) {
+ if (n > 1) printf "if (NR==%d)", final
+ printf "sp(%d);", d2 - d1
+ }
+ }
+ printf "next}\n" ;
+
+ next
+ }
+ }
+
+ END { printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
+ ' /tmp/$$.diffs > /tmp/$$.file1
+
+ #
+ # Now generate the HTML for the new file
+ #
+ $AWK '
+ BEGIN {
+ printf "function sp(n) {for (i=0;i%%4d %%s\\n\", NR, $0}\n"
+ printf "function changed() "
+ printf "{printf \"%%4d %%s\\n\", NR, $0}\n"
+ printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
+ }
+
+ /^ {next}
+ /^>/ {next}
+ /^---/ {next}
+
+ {
+ split($1, a, /[cad]/) ;
+ if (index($1, "d")) {
+ if (a[2] == 0) {
+ n = split(a[1], r, /,/);
+ if (n == 1)
+ printf "BEGIN\t\t{sp(1)}\n"
+ else
+ printf "BEGIN\t\t{sp(%d)}\n",\
+ (r[2] - r[1]) + 1
+ next
+ }
+
+ printf "NR==%s\t\t{", a[2]
+ n = split(a[1], r, /,/);
+ s = r[1];
+ if (n == 1)
+ printf "bl();printf \"\\n\"; next}\n"
+ else {
+ n = r[2] - r[1]
+ printf "bl();sp(%d);next}\n",\
+ (r[2] - r[1]) + 1
+ }
+ next
+ }
+ if (index($1, "a")) {
+ n = split(a[2], r, /,/);
+ n1 = r[1]
+ n2 = r[2]
+ if (n == 1)
+ printf "NR==%s\t\t{new() ; next}\n" , n1
+ else
+ printf "NR==%s,NR==%s\t{new() ; next}\n" , n1, n2
+ next
+ }
+ if (index($1, "c")) {
+ n = split(a[2], r, /,/);
+ n1 = r[1]
+ n2 = r[2]
+ final = n2
+ d2 = 0;
+ if (n == 1) {
+ final = n1
+ printf "NR==%s\t\t{changed();" , n1
+ } else {
+ d2 = n2 - n1
+ printf "NR==%s,NR==%s\t{changed();" , n1, n2
+ }
+ m = split(a[1], r, /,/);
+ n1 = r[1]
+ n2 = r[2]
+ if (m > 1) {
+ d1 = n2 - n1
+ if (d1 > d2) {
+ if (n > 1) printf "if (NR==%d)", final
+ printf "sp(%d);", d1 - d2
+ }
+ }
+ printf "next}\n" ;
+ next
+ }
+ }
+ END { printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
+ ' /tmp/$$.diffs > /tmp/$$.file2
+
+ #
+ # Post-process the HTML files by running them back through $AWK
+ #
+ html_quote < $1 | $AWK -f /tmp/$$.file1 > /tmp/$$.file1.html
+
+ html_quote < $2 | $AWK -f /tmp/$$.file2 > /tmp/$$.file2.html
+
+ #
+ # Now combine into a valid HTML file and side-by-side into a table
+ #
+ print "$HTML$STDHEAD"
+ print "$WNAME Sdiff $TPATH "
+ print ""
+ print "$TPATH/$TNAME
"
+ print "Print this page"
+ print "$COMMENT
\n"
+ print ""
+ print ""
+
+ strip_unchanged /tmp/$$.file1.html
+
+ print "
"
+
+ strip_unchanged /tmp/$$.file2.html
+
+ print "
"
+ print "
"
+ print ""
+
+ framed_sdiff $TNAME $TPATH /tmp/$$.file1.html /tmp/$$.file2.html \
+ "$COMMENT"
+}
+
+
+#
+# framed_sdiff
+#
+# Expects lefthand and righthand side html files created by sdiff_to_html.
+# We use insert_anchors() to augment those with HTML navigation anchors,
+# and then emit the main frame. Content is placed into:
+#
+# $WDIR/DIR/$TNAME.lhs.html
+# $WDIR/DIR/$TNAME.rhs.html
+# $WDIR/DIR/$TNAME.frames.html
+#
+# NOTE: We rely on standard usage of $WDIR and $DIR.
+#
+function framed_sdiff
+{
+ typeset TNAME=$1
+ typeset TPATH=$2
+ typeset lhsfile=$3
+ typeset rhsfile=$4
+ typeset comments=$5
+ typeset RTOP
+
+ # Enable html files to access WDIR via a relative path.
+ RTOP=$(relative_dir $TPATH $WDIR)
+
+ # Make the rhs/lhs files and output the frameset file.
+ print "$HTML$STDHEAD" > $WDIR/$DIR/$TNAME.lhs.html
+
+ cat >> $WDIR/$DIR/$TNAME.lhs.html <<-EOF
+
+
+
+
+ $comments
+ EOF
+
+ cp $WDIR/$DIR/$TNAME.lhs.html $WDIR/$DIR/$TNAME.rhs.html
+
+ insert_anchors $lhsfile >> $WDIR/$DIR/$TNAME.lhs.html
+ insert_anchors $rhsfile >> $WDIR/$DIR/$TNAME.rhs.html
+
+ close=''
+
+ print $close >> $WDIR/$DIR/$TNAME.lhs.html
+ print $close >> $WDIR/$DIR/$TNAME.rhs.html
+
+ print "$FRAMEHTML$STDHEAD" > $WDIR/$DIR/$TNAME.frames.html
+ print "$WNAME Framed-Sdiff " \
+ "$TPATH/$TNAME " >> $WDIR/$DIR/$TNAME.frames.html
+ cat >> $WDIR/$DIR/$TNAME.frames.html <<-EOF
+
+