make/scripts/webrev.ksh

changeset 616
168dd033604a
parent 314
47ad81d343e8
child 643
c641268c4532
equal deleted inserted replaced
615:8dd61906da5f 616:168dd033604a
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'
144 # 144 #
145 # Scan for bugids and insert <a> links to the relevent bug database. 145 # Scan for bugids and insert <a> links to the relevent bug database.
146 # 146 #
147 bug2url() 147 bug2url()
148 { 148 {
149 sed -e 's|[0-9]\{5,\}|<a href=\"'$BUGURL'&\">&</a>|g' 149 sed -e 's|[0-9]\{5,\}|<a href=\"'$BUGURL$IDPREFIX'&\">&</a>|g'
150 } 150 }
151 151
152 # 152 #
153 # input_cmd | sac2url | output_cmd 153 # input_cmd | sac2url | output_cmd
154 # 154 #
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
1158 fi 1158 fi
1159 if [[ $fmt == "text" ]]; then 1159 if [[ $fmt == "text" ]]; then
1160 print "$comm" 1160 print "$comm"
1161 return 1161 return
1162 fi 1162 fi
1163 1163
1164 print "$comm" | html_quote | bug2url | sac2url 1164 print "$comm" | html_quote | bug2url | sac2url
1165 ) 1165 )
1166 fi 1166 fi
1167 } 1167 }
1168 1168
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
1457 # 1457 #
1458 function treestatus 1458 function treestatus
1459 { 1459 {
1460 TREE=$1 1460 TREE=$1
1461 HGCMD="hg -R $CWS/$TREE status $FSTAT_OPT" 1461 HGCMD="hg -R $CWS/$TREE status $FSTAT_OPT"
1462 1462
1463 $HGCMD -mdn 2>/dev/null | $FILTER | while read F 1463 $HGCMD -mdn 2>/dev/null | $FILTER | while read F
1464 do 1464 do
1465 echo $TREE/$F 1465 echo $TREE/$F
1466 done >> $FLIST 1466 done >> $FLIST
1467 1467
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
1842 else 1842 else
1843 ssh_user= 1843 ssh_user=
1844 ssh_host=`echo $CMD | sed -e 's/ssh:\/\/\([^/]*\)\/.*/\1/'` 1844 ssh_host=`echo $CMD | sed -e 's/ssh:\/\/\([^/]*\)\/.*/\1/'`
1845 ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/[^/]*\/\(.*\)/\1/'` 1845 ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/[^/]*\/\(.*\)/\1/'`
1846 fi 1846 fi
1847 1847
1848 } 1848 }
1849 1849
1850 function build_old_new_mercurial 1850 function build_old_new_mercurial
1851 { 1851 {
1852 olddir=$1 1852 olddir=$1
2094 2094
2095 r) rflag=1 2095 r) rflag=1
2096 PARENT_REV=$OPTARG;; 2096 PARENT_REV=$OPTARG;;
2097 2097
2098 v) print "$0 version: $WEBREV_UPDATED";; 2098 v) print "$0 version: $WEBREV_UPDATED";;
2099 2099
2100 2100
2101 ?) usage;; 2101 ?) usage;;
2102 esac 2102 esac
2103 done 2103 done
2104 2104
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 #
2559 rm -rf $WDIR/raw_files 2>/dev/null 2565 rm -rf $WDIR/raw_files 2>/dev/null
2560 fi 2566 fi
2561 2567
2562 # 2568 #
2563 # Should we ignore changes in white spaces when generating diffs? 2569 # Should we ignore changes in white spaces when generating diffs?
2564 # 2570 #
2565 if [[ -n $bflag ]]; then 2571 if [[ -n $bflag ]]; then
2566 DIFFOPTS="-t" 2572 DIFFOPTS="-t"
2567 else 2573 else
2568 DIFFOPTS="-bt" 2574 DIFFOPTS="-bt"
2569 fi 2575 fi
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>"
3177 exec 1<&3 # dup FD 3 to restore stdout. 3192 exec 1<&3 # dup FD 3 to restore stdout.
3178 exec 3<&- # close FD 3. 3193 exec 3<&- # close FD 3.
3179 3194
3180 print "Done." 3195 print "Done."
3181 print "Output to: $WDIR" 3196 print "Output to: $WDIR"
3182

mercurial