17 # fields enclosed by brackets "[]" replaced with your own identifying |
17 # fields enclosed by brackets "[]" replaced with your own identifying |
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
19 # |
19 # |
20 # CDDL HEADER END |
20 # CDDL HEADER END |
21 # |
21 # |
22 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
22 # Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
23 # Use is subject to license terms. |
23 # Use is subject to license terms. |
24 # |
24 # |
25 # This script takes a file list and a workspace and builds a set of html files |
25 # This script takes a file list and a workspace and builds a set of html files |
26 # suitable for doing a code review of source changes via a web page. |
26 # suitable for doing a code review of source changes via a web page. |
27 # Documentation is available via 'webrev -h'. |
27 # Documentation is available via 'webrev -h'. |
28 # |
28 # |
29 |
29 |
30 WEBREV_UPDATED=23.18-hg |
30 WEBREV_UPDATED=23.18-hg+jbs |
31 |
31 |
32 HTML='<?xml version="1.0"?> |
32 HTML='<?xml version="1.0"?> |
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
34 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
34 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
35 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' |
35 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' |
228 # e.g. |
228 # e.g. |
229 # |
229 # |
230 # $ sdiff_to_html old/usr/src/tools/scripts/webrev.sh \ |
230 # $ sdiff_to_html old/usr/src/tools/scripts/webrev.sh \ |
231 # new/usr/src/tools/scripts/webrev.sh \ |
231 # new/usr/src/tools/scripts/webrev.sh \ |
232 # webrev.sh usr/src/tools/scripts \ |
232 # webrev.sh usr/src/tools/scripts \ |
233 # '<a href="http://monaco.sfbay.sun.com/detail.jsp?cr=1234567"> |
233 # '<a href="https://jbs.oracle.com/bugs/browse/JDK-1234567"> |
234 # 1234567</a> my bugid' > <file>.html |
234 # JDK-1234567</a> my bugid' > <file>.html |
235 # |
235 # |
236 # framed_sdiff() is then called which creates $2.frames.html |
236 # framed_sdiff() is then called which creates $2.frames.html |
237 # in the webrev tree. |
237 # in the webrev tree. |
238 # |
238 # |
239 # FYI: This function is rather unusual in its use of awk. The initial |
239 # FYI: This function is rather unusual in its use of awk. The initial |
1416 if (revs[tree] == -1 || rev < revs[tree]) |
1416 if (revs[tree] == -1 || rev < revs[tree]) |
1417 { revs[tree] = rev; }; |
1417 { revs[tree] = rev; }; |
1418 next;} |
1418 next;} |
1419 END {for (tree in trees) |
1419 END {for (tree in trees) |
1420 { rev=revs[trees[tree]]; |
1420 { rev=revs[trees[tree]]; |
1421 if (rev > 0) |
1421 if (rev > 0) |
1422 {printf("%s %d\n",trees[tree],rev-1)} |
1422 {printf("%s %d\n",trees[tree],rev-1)} |
1423 }}' | while read LINE |
1423 }}' | while read LINE |
1424 do |
1424 do |
1425 set - $LINE |
1425 set - $LINE |
1426 TREE=$1 |
1426 TREE=$1 |
1541 /^\[.*\]$/ {tree=substr($1,2,length($1)-2); next} |
1541 /^\[.*\]$/ {tree=substr($1,2,length($1)-2); next} |
1542 /^A .*/ {n=index($2,tree); |
1542 /^A .*/ {n=index($2,tree); |
1543 if (n == 0) |
1543 if (n == 0) |
1544 { printf("A %s/%s\n",tree,$2)} |
1544 { printf("A %s/%s\n",tree,$2)} |
1545 else |
1545 else |
1546 { printf("A %s\n",$2)}; |
1546 { printf("A %s\n",$2)}; |
1547 next} |
1547 next} |
1548 /^ / {n=index($1,tree); |
1548 /^ / {n=index($1,tree); |
1549 if (n == 0) |
1549 if (n == 0) |
1550 { printf("%s/%s\n",tree,$1)} |
1550 { printf("%s/%s\n",tree,$1)} |
1551 else |
1551 else |
1602 # run hg commit. If we don't find any then we look with hg status. |
1602 # run hg commit. If we don't find any then we look with hg status. |
1603 # |
1603 # |
1604 # We need at least one of default-push or default paths set in .hg/hgrc |
1604 # We need at least one of default-push or default paths set in .hg/hgrc |
1605 # If neither are set we don't know who to compare with. |
1605 # If neither are set we don't know who to compare with. |
1606 |
1606 |
1607 function flist_from_mercurial |
1607 function flist_from_mercurial |
1608 { |
1608 { |
1609 # if [ "${PWS##ssh://}" != "$PWS" -o \ |
1609 # if [ "${PWS##ssh://}" != "$PWS" -o \ |
1610 # "${PWS##http://}" != "$PWS" -o \ |
1610 # "${PWS##http://}" != "$PWS" -o \ |
1611 # "${PWS##https://}" != "$PWS" ]; then |
1611 # "${PWS##https://}" != "$PWS" ]; then |
1612 # print "Remote Mercurial repositories not currently supported." |
1612 # print "Remote Mercurial repositories not currently supported." |
1755 if [[ "$OS" == "SunOS" ]]; then |
1755 if [[ "$OS" == "SunOS" ]]; then |
1756 DEVTOOLS="/java/devtools/`uname -p`/bin" |
1756 DEVTOOLS="/java/devtools/`uname -p`/bin" |
1757 elif [[ "$OS" == "Linux" ]]; then |
1757 elif [[ "$OS" == "Linux" ]]; then |
1758 DEVTOOLS="/java/devtools/linux/bin" |
1758 DEVTOOLS="/java/devtools/linux/bin" |
1759 fi |
1759 fi |
1760 |
1760 |
1761 ppath=$PATH |
1761 ppath=$PATH |
1762 ppath=$ppath:/usr/sfw/bin:/usr/bin:/usr/sbin |
1762 ppath=$ppath:/usr/sfw/bin:/usr/bin:/usr/sbin |
1763 ppath=$ppath:/opt/teamware/bin:/opt/onbld/bin |
1763 ppath=$ppath:/opt/teamware/bin:/opt/onbld/bin |
1764 ppath=$ppath:/opt/onbld/bin/`uname -p` |
1764 ppath=$ppath:/opt/onbld/bin/`uname -p` |
1765 ppath=$ppath:/java/devtools/share/bin:$DEVTOOLS |
1765 ppath=$ppath:/java/devtools/share/bin:$DEVTOOLS |
2336 # |
2336 # |
2337 # Here is case (2): the user environment |
2337 # Here is case (2): the user environment |
2338 # |
2338 # |
2339 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS |
2339 [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS |
2340 [[ -z $codemgr_ws && -n $WSPACE ]] && codemgr_ws=`$WSPACE name` |
2340 [[ -z $codemgr_ws && -n $WSPACE ]] && codemgr_ws=`$WSPACE name` |
2341 |
2341 |
2342 if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then |
2342 if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then |
2343 print -u2 "$codemgr_ws: no such workspace" |
2343 print -u2 "$codemgr_ws: no such workspace" |
2344 exit 1 |
2344 exit 1 |
2345 fi |
2345 fi |
2346 |
2346 |
2519 |
2519 |
2520 # |
2520 # |
2521 # Bug IDs will be replaced by a URL. Order of precedence |
2521 # Bug IDs will be replaced by a URL. Order of precedence |
2522 # is: default location, $WEBREV_BUGURL, the -O flag. |
2522 # is: default location, $WEBREV_BUGURL, the -O flag. |
2523 # |
2523 # |
2524 BUGURL='http://monaco.sfbay.sun.com/detail.jsp?cr=' |
2524 BUGURL='https://jbs.oracle.com/bugs/browse/' |
2525 [[ -n $WEBREV_BUGURL ]] && BUGURL="$WEBREV_BUGURL" |
2525 [[ -n $WEBREV_BUGURL ]] && BUGURL="$WEBREV_BUGURL" |
2526 [[ -n "$Oflag" ]] && \ |
2526 if [[ -n "$Oflag" ]]; then |
|
2527 CRID=`echo $CRID | sed -e 's/JDK-//'` |
2527 BUGURL='http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=' |
2528 BUGURL='http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=' |
|
2529 IDPREFIX='' |
|
2530 else |
|
2531 IDPREFIX='JDK-' |
|
2532 fi |
|
2533 |
2528 |
2534 |
2529 # |
2535 # |
2530 # Likewise, ARC cases will be replaced by a URL. Order of precedence |
2536 # Likewise, ARC cases will be replaced by a URL. Order of precedence |
2531 # is: default, $WEBREV_SACURL, the -O flag. |
2537 # is: default, $WEBREV_SACURL, the -O flag. |
2532 # |
2538 # |
2746 # old file: count deleted lines |
2752 # old file: count deleted lines |
2747 difflines $ofile.lst /dev/null > $WDIR/$DIR/$F.count |
2753 difflines $ofile.lst /dev/null > $WDIR/$DIR/$F.count |
2748 fi |
2754 fi |
2749 fi |
2755 fi |
2750 else |
2756 else |
2751 |
2757 |
2752 # |
2758 # |
2753 # If we have old and new versions of the file then run the |
2759 # If we have old and new versions of the file then run the |
2754 # appropriate diffs. This is complicated by a couple of factors: |
2760 # appropriate diffs. This is complicated by a couple of factors: |
2755 # |
2761 # |
2756 # - renames must be handled specially: we emit a 'remove' |
2762 # - renames must be handled specially: we emit a 'remove' |
2998 fi |
3004 fi |
2999 # Add links to referenced CRs, if any |
3005 # Add links to referenced CRs, if any |
3000 # external URL has a <title> like: |
3006 # external URL has a <title> like: |
3001 # <title>Bug ID: 6641309 Wrong Cookie separator used in HttpURLConnection</title> |
3007 # <title>Bug ID: 6641309 Wrong Cookie separator used in HttpURLConnection</title> |
3002 # while internal URL has <title> like: |
3008 # while internal URL has <title> like: |
3003 # <title>6641309: Wrong Cookie separator used in HttpURLConnection</title> |
3009 # <title>[#JDK-6641309] Wrong Cookie separator used in HttpURLConnection</title> |
3004 # |
3010 # |
3005 if [[ -n $CRID ]]; then |
3011 if [[ -n $CRID ]]; then |
3006 for id in $CRID |
3012 for id in $CRID |
3007 do |
3013 do |
|
3014 if [[ -z "$Oflag" ]]; then |
|
3015 #add "JDK-" to raw bug id for jbs links. |
|
3016 id=`echo ${id} | sed 's/^\([0-9]\{5,\}\)$/JDK-\1/'` |
|
3017 fi |
3008 print "<tr><th>Bug id:</th><td>" |
3018 print "<tr><th>Bug id:</th><td>" |
3009 url="${BUGURL}${id}" |
3019 url="${BUGURL}${id}" |
|
3020 if [[ -n "$Oflag" ]]; then |
|
3021 cleanup='s/Bug ID: \([0-9]\{5,\}\) \(.*\)/JDK-\1 : \2/' |
|
3022 else |
|
3023 cleanup='s|\[#\(JDK-[0-9]\{5,\}\)\] \(.*\)|\1 : \2|' |
|
3024 fi |
3010 if [[ -n $WGET ]]; then |
3025 if [[ -n $WGET ]]; then |
3011 msg=`$WGET -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed 's/Bug ID://'` |
3026 msg=`$WGET --timeout=10 --tries=1 -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed "$cleanup"` |
3012 fi |
3027 fi |
3013 if [[ -n $msg ]]; then |
3028 if [[ -z $msg ]]; then |
3014 print "<a href=\"$url\">$msg</a>" |
3029 msg="${id}" |
3015 else |
|
3016 print $id | bug2url |
|
3017 fi |
3030 fi |
3018 |
3031 |
|
3032 print "<a href=\"$url\">$msg</a>" |
|
3033 |
3019 print "</td></tr>" |
3034 print "</td></tr>" |
3020 done |
3035 done |
3021 fi |
3036 fi |
3022 print "<tr><th>Legend:</th><td>" |
3037 print "<tr><th>Legend:</th><td>" |
3023 print "<b>Modified file</b><br><font color=red><b>Deleted file</b></font><br><font color=green><b>New file</b></font></td></tr>" |
3038 print "<b>Modified file</b><br><font color=red><b>Deleted file</b></font><br><font color=green><b>New file</b></font></td></tr>" |