diff options
author | Joshua M. Clulow <jmc@joyent.com> | 2016-04-06 23:40:59 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2016-06-09 23:23:27 -0700 |
commit | b0efaad712c1765eaff91438c867d7aa898465b6 (patch) | |
tree | 1bc14df50ad881b7767ae765fe1d6075ae508bbe /usr/src/tools/scripts/webrev.sh | |
parent | bc07d1fd58f705e3a6d5b418433e42cd8e42b7f1 (diff) | |
download | illumos-gate-b0efaad712c1765eaff91438c867d7aa898465b6.tar.gz |
7065 webrev could use a style cleanup
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/tools/scripts/webrev.sh')
-rw-r--r-- | usr/src/tools/scripts/webrev.sh | 231 |
1 files changed, 123 insertions, 108 deletions
diff --git a/usr/src/tools/scripts/webrev.sh b/usr/src/tools/scripts/webrev.sh index 5fbed75864..a10bdbd1bc 100644 --- a/usr/src/tools/scripts/webrev.sh +++ b/usr/src/tools/scripts/webrev.sh @@ -294,20 +294,20 @@ function remote_mkdirs "cannot create temporary file for batch file" return 1 fi - OLDIFS=$IFS - IFS=/ + OLDIFS=$IFS + IFS=/ typeset dir - for dir in ${dirs_mk}; do + for dir in ${dirs_mk}; do # # Use the '-' prefix to ignore mkdir errors in order # to avoid an error in case the directory already # exists. We check the directory with chdir to be sure # there is one. # - print -- "-mkdir ${dir}" >> ${batch_file_mkdir} - print "chdir ${dir}" >> ${batch_file_mkdir} - done - IFS=$OLDIFS + print -- "-mkdir ${dir}" >> ${batch_file_mkdir} + print "chdir ${dir}" >> ${batch_file_mkdir} + done + IFS=$OLDIFS typeset -r sftp_err_msg=$( $MKTEMP /tmp/webrev_scp_err.XXXXXX ) if [[ -z ${sftp_err_msg} ]]; then print "\nERROR: remote_mkdirs:" \ @@ -891,7 +891,7 @@ sdiff_to_html() print "$HTML<head>$STDHEAD" print "<title>$WNAME Sdiff $TPATH/$TNAME</title>" print "</head><body id=\"SUNWwebrev\">" - print "<a class=\"print\" href=\"javascript:print()\">Print this page</a>" + print "<a class=\"print\" href=\"javascript:print()\">Print this page</a>" print "<pre>$COMMENT</pre>\n" print "<table><tr valign=\"top\">" print "<td><pre>" @@ -969,10 +969,10 @@ function framed_sdiff <frame src="${RTOP}ancnav.html" scrolling="no" marginwidth="0" marginheight="0" name="nav"></frame> <noframes> - <body id="SUNWwebrev"> + <body id="SUNWwebrev"> Alas 'frames' webrev requires that your browser supports frames and has the feature enabled. - </body> + </body> </noframes> </frameset> </html> @@ -1110,20 +1110,20 @@ function insert_anchors # function relative_dir { - typeset cur="${1##$2?(/)}" - - # - # If the first path was specified absolutely, and it does - # not start with the second path, it's an error. - # - if [[ "$cur" = "/${1#/}" ]]; then - # Should never happen. - print -u2 "\nWARNING: relative_dir: \"$1\" not relative " - print -u2 "to \"$2\". Check input paths. Framed webrev " - print -u2 "will not be relocatable!" - print $2 - return - fi + typeset cur="${1##$2?(/)}" + + # + # If the first path was specified absolutely, and it does + # not start with the second path, it's an error. + # + if [[ "$cur" = "/${1#/}" ]]; then + # Should never happen. + print -u2 "\nWARNING: relative_dir: \"$1\" not relative " + print -u2 "to \"$2\". Check input paths. Framed webrev " + print -u2 "will not be relocatable!" + print $2 + return + fi # # This is kind of ugly. The sed script will do the following: @@ -1157,22 +1157,23 @@ function frame_nav_js { cat << \EOF var myInt; -var scrolling=0; +var scrolling = 0; var sfactor = 3; -var scount=10; +var scount = 10; -function scrollByPix() { - if (scount<=0) { - sfactor*=1.2; - scount=10; +function scrollByPix() +{ + if (scount <= 0) { + sfactor *= 1.2; + scount = 10; } - parent.lhs.scrollBy(0,sfactor); - parent.rhs.scrollBy(0,sfactor); + parent.lhs.scrollBy(0, sfactor); + parent.rhs.scrollBy(0, sfactor); scount--; } -function scrollToAnc(num) { - +function scrollToAnc(num) +{ // Update the value of the anchor in the form which we use as // storage for this value. setAncValue() will take care of // correcting for overflow and underflow of the value and return @@ -1189,8 +1190,8 @@ function scrollToAnc(num) { parent.lhs.location.replace(parent.lhs.location.pathname + "#" + num); parent.rhs.location.replace(parent.rhs.location.pathname + "#" + num); - parent.lhs.scrollBy(0,-30); - parent.rhs.scrollBy(0,-30); + parent.lhs.scrollBy(0, -30); + parent.rhs.scrollBy(0, -30); } function getAncValue() @@ -1226,50 +1227,54 @@ function setAncValue(val) return (val); } -function stopScroll() { - if (scrolling==1) { +function stopScroll() +{ + if (scrolling == 1) { clearInterval(myInt); - scrolling=0; + scrolling = 0; } } -function startScroll() { +function startScroll() +{ stopScroll(); - scrolling=1; - myInt=setInterval("scrollByPix()",10); + scrolling = 1; + myInt = setInterval("scrollByPix()", 10); } -function handlePress(b) { - +function handlePress(b) +{ switch (b) { - case 1 : + case 1: scrollToAnc(-1); break; - case 2 : + case 2: scrollToAnc(getAncValue() - 1); break; - case 3 : - sfactor=-3; + case 3: + sfactor = -3; startScroll(); break; - case 4 : - sfactor=3; + case 4: + sfactor = 3; startScroll(); break; - case 5 : + case 5: scrollToAnc(getAncValue() + 1); break; - case 6 : + case 6: scrollToAnc(999999); break; } } -function handleRelease(b) { +function handleRelease(b) +{ stopScroll(); } -function keypress(ev) { +function keypress(ev) +{ var keynum; var keychar; @@ -1288,10 +1293,15 @@ function keypress(ev) { handlePress(5); return (0); } + return (1); } -function ValidateDiffNum(){ +function ValidateDiffNum() +{ + var val; + var i; + val = parent.nav.document.diff.display.value; if (val == "EOF") { scrollToAnc(999999); @@ -1303,15 +1313,15 @@ function ValidateDiffNum(){ return; } - i=parseInt(val); - if (isNaN(i)) { - parent.nav.document.diff.display.value = getAncValue(); - } else { - scrollToAnc(i); - } - return false; -} + i = parseInt(val); + if (isNaN(i)) { + parent.nav.document.diff.display.value = getAncValue(); + } else { + scrollToAnc(i); + } + return (false); +} EOF } @@ -1582,8 +1592,8 @@ function difflines /^[0-9]*,[0-9]*c$/ { n=split(substr($1,1,length($1)-1), counts, ","); if (n != 2) { - error=2 - exit; + error=2 + exit; } # # 3,5c means lines 3 , 4 and 5 are changed, a total of 3 lines. @@ -2001,25 +2011,25 @@ function build_old_new_git if [[ "$PDIR" == "." ]]; then file="$PF" else - file="$PDIR/$PF" + file="$PDIR/$PF" fi if [[ -n $parent_webrev && -e $PWS/$PDIR/$PF ]]; then cp $PWS/$PDIR/$PF $olddir/$PDIR/$PF else - $GIT ls-tree $GIT_PARENT $file | read o_mode type o_object junk - $GIT cat-file $type $o_object > $olddir/$file 2>/dev/null - - if (( $? != 0 )); then - rm -f $olddir/$file - elif [[ -n $o_mode ]]; then - # Strip the first 3 digits, to get a regular octal mode - o_mode=${o_mode/???/} - chmod $o_mode $olddir/$file - else - # should never happen - print -u2 "ERROR: set mode of $olddir/$file" - fi + $GIT ls-tree $GIT_PARENT $file | read o_mode type o_object junk + $GIT cat-file $type $o_object > $olddir/$file 2>/dev/null + + if (( $? != 0 )); then + rm -f $olddir/$file + elif [[ -n $o_mode ]]; then + # Strip the first 3 digits, to get a regular octal mode + o_mode=${o_mode/???/} + chmod $o_mode $olddir/$file + else + # should never happen + print -u2 "ERROR: set mode of $olddir/$file" + fi fi # @@ -2033,8 +2043,8 @@ function build_old_new_git rm -rf $newdir/$file if [[ -e $CWS/$DIR/$F ]]; then - cp $CWS/$DIR/$F $newdir/$DIR/$F - chmod $(get_file_mode $CWS/$DIR/$F) $newdir/$DIR/$F + cp $CWS/$DIR/$F $newdir/$DIR/$F + chmod $(get_file_mode $CWS/$DIR/$F) $newdir/$DIR/$F fi cd $OWD } @@ -2329,7 +2339,7 @@ if [[ $SCM_MODE == "mercurial" ]]; then exit 1 fi else - testparent=${CODEMGR_WS} + testparent=${CODEMGR_WS} fi [[ -z $codemgr_ws && -n $testparent ]] && \ codemgr_ws=$(hg root -R $testparent 2>/dev/null) @@ -2343,7 +2353,7 @@ elif [[ $SCM_MODE == "git" ]]; then # [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && \ codemgr_ws=$($GIT --git-dir=$CODEMGR_WS/.git rev-parse --git-dir \ - 2>/dev/null) + 2>/dev/null) [[ -z $codemgr_ws ]] && \ codemgr_ws=$($GIT rev-parse --git-dir 2>/dev/null) @@ -2607,13 +2617,16 @@ elif [[ $SCM_MODE == "git" ]]; then this_branch=$($GIT branch | nawk '$1 == "*" { print $2 }') par_branch="origin/master" - # If we're not on a branch there's nothing we can do - if [[ $this_branch != "(no branch)" ]]; then - $GIT for-each-ref \ - --format='%(refname:short) %(upstream:short)' refs/heads/ | \ - while read local remote; do \ - [[ "$local" == "$this_branch" ]] && par_branch="$remote"; \ - done + # If we're not on a branch there's nothing we can do + if [[ $this_branch != "(no branch)" ]]; then + $GIT for-each-ref \ + --format='%(refname:short) %(upstream:short)' \ + refs/heads/ | \ + while read local remote; do + if [[ "$local" == "$this_branch" ]]; then + par_branch="$remote" + fi + done fi if [[ -z $codemgr_parent ]]; then @@ -2697,26 +2710,28 @@ elif [[ $SCM_MODE == "subversion" ]]; then flist_from_subversion $CWS $OLDPWD fi else - if [[ $SCM_MODE == "unknown" ]]; then - print -u2 " Unknown type of SCM in use" - else - print -u2 " Unsupported SCM in use: $SCM_MODE" - fi + if [[ $SCM_MODE == "unknown" ]]; then + print -u2 " Unknown type of SCM in use" + else + print -u2 " Unsupported SCM in use: $SCM_MODE" + fi - env_from_flist + env_from_flist - if [[ -z $CODEMGR_WS ]]; then - print -u2 "SCM not detected/supported and CODEMGR_WS not specified" - exit 1 - fi + if [[ -z $CODEMGR_WS ]]; then + print -u2 "SCM not detected/supported and " \ + "CODEMGR_WS not specified" + exit 1 + fi - if [[ -z $CODEMGR_PARENT ]]; then - print -u2 "SCM not detected/supported and CODEMGR_PARENT not specified" - exit 1 - fi + if [[ -z $CODEMGR_PARENT ]]; then + print -u2 "SCM not detected/supported and " \ + "CODEMGR_PARENT not specified" + exit 1 + fi - CWS=$CODEMGR_WS - PWS=$CODEMGR_PARENT + CWS=$CODEMGR_WS + PWS=$CODEMGR_PARENT fi # @@ -3068,7 +3083,7 @@ do F=${P##*/} - else + else DIR=${P%/*} if [[ "$DIR" == "$P" ]]; then DIR="." # File at root of workspace @@ -3120,7 +3135,7 @@ do # - renames must be handled specially: we emit a 'remove' # diff and an 'add' diff # - new files and deleted files must be handled specially - # - GNU patch doesn't interpret the output of illumos diff + # - GNU patch doesn't interpret the output of illumos diff # properly when it comes to adds and deletes. We need to # do some "cleansing" transformations: # [to add a file] @@ -1,0 +X,Y @@ --> @@ -0,0 +X,Y @@ |