diff options
author | Yuri Pankov <yuri.pankov@nexenta.com> | 2016-03-26 19:35:23 +0300 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2016-04-07 08:59:38 -0700 |
commit | 44f180b8a623d69ee5f5ed55ebcb61e1fef6205e (patch) | |
tree | 6fd07cc2075fb93b129dc6fd902b5439780c413b /usr/src/tools/scripts/webrev.sh | |
parent | 62dadd654b88164ac263978699c78aa01647a39b (diff) | |
download | illumos-gate-44f180b8a623d69ee5f5ed55ebcb61e1fef6205e.tar.gz |
6857 webrev: add -c and -h options to specify "head" revision
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/tools/scripts/webrev.sh')
-rw-r--r-- | usr/src/tools/scripts/webrev.sh | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/usr/src/tools/scripts/webrev.sh b/usr/src/tools/scripts/webrev.sh index 78a66359b9..5fbed75864 100644 --- a/usr/src/tools/scripts/webrev.sh +++ b/usr/src/tools/scripts/webrev.sh @@ -25,7 +25,7 @@ # Copyright 2008, 2010, Richard Lowe # Copyright 2012 Marcel Telka <marcel@telka.sk> # Copyright 2014 Bart Coddens <bart.coddens@gmail.com> -# Copyright 2015 Nexenta Systems, Inc. All rights reserved. +# Copyright 2016 Nexenta Systems, Inc. # # @@ -1766,9 +1766,10 @@ function git_wxfile TMPFLIST=/tmp/$$.active $PERL -e 'my (%files, %realfiles, $msg); - my $branch = $ARGV[0]; + my $parent = $ARGV[0]; + my $child = $ARGV[1]; - open(F, "git diff -M --name-status $branch |"); + open(F, "git diff -M --name-status $parent..$child |"); while (<F>) { chomp; if (/^R(\d+)\s+([^ ]+)\s+([^ ]+)/) { # rename @@ -1786,7 +1787,7 @@ function git_wxfile close(F); my $state = 1; # 0|comments, 1|files - open(F, "git whatchanged --pretty=format:%B $branch.. |"); + open(F, "git whatchanged --pretty=format:%B $parent..$child |"); while (<F>) { chomp; if (/^:[0-9]{6}/) { @@ -1811,7 +1812,7 @@ function git_wxfile } else { print "$_\n$files{$_}\n\n" } - }' ${parent} > $TMPFLIST + }' ${parent} ${child} > $TMPFLIST wxfile=$TMPFLIST } @@ -2122,8 +2123,10 @@ function usage webrev [common-options] -w <wx file> Options: + -c <revision>: generate webrev for single revision (git only) -C <filename>: Use <filename> for the information tracking configuration. -D: delete remote webrev + -h <revision>: specify "head" revision for comparison (git only) -i <filename>: Include <filename> in the index.html file. -I <filename>: Use <filename> for the information tracking registry. -n: do not generate the webrev (useful with -U) @@ -2213,10 +2216,12 @@ typeset -r DEFAULT_REMOTE_HOST="cr.opensolaris.org" typeset -r rsync_prefix="rsync://" typeset -r ssh_prefix="ssh://" +cflag= Cflag= Dflag= flist_mode= flist_file= +hflag= iflag= Iflag= lflag= @@ -2235,14 +2240,21 @@ remote_target= # NOTE: when adding/removing options it is necessary to sync the list # with usr/src/tools/onbld/hgext/cdm.py # -while getopts "C:Di:I:lnNo:Op:t:Uw" opt +while getopts "c:C:Dh:i:I:lnNo:Op:t:Uw" opt do case $opt in + c) cflag=1 + codemgr_head=$OPTARG + codemgr_parent=$OPTARG~1;; + C) Cflag=1 ITSCONF=$OPTARG;; D) Dflag=1;; + h) hflag=1 + codemgr_head=$OPTARG;; + i) iflag=1 INCLUDE_FILE=$OPTARG;; @@ -2571,11 +2583,21 @@ if [[ $SCM_MODE == "mercurial" ]]; then 2>/dev/null) PRETTY_CWS="${CWS} (at ${cnode})"} elif [[ $SCM_MODE == "git" ]]; then - # + # Check that "head" revision specified with -c or -h is sane + if [[ -n $cflag || -n $hflag ]]; then + head_rev=$($GIT rev-parse --verify --quiet "$codemgr_head") + if [[ -z $head_rev ]]; then + print -u2 "Error: bad revision ${codemgr_head}" + exit 1 + fi + fi + + if [[ -z $codemgr_head ]]; then + codemgr_head="HEAD"; + fi + # Parent can either be specified with -p, or specified with # CODEMGR_PARENT in the environment. - # - if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then codemgr_parent=$CODEMGR_PARENT fi @@ -2610,7 +2632,7 @@ elif [[ $SCM_MODE == "git" ]]; then fi if [[ -z $flist_done ]]; then - flist_from_git "$CWS" "$real_parent" + flist_from_git "$codemgr_head" "$real_parent" flist_done=1 fi @@ -2628,12 +2650,12 @@ elif [[ $SCM_MODE == "git" ]]; then # if [[ -z $wxfile ]]; then print " Comments from: git...\c" - git_wxfile "$CWS" "$real_parent" + git_wxfile "$codemgr_head" "$real_parent" print " Done." fi if [[ -z $GIT_PARENT ]]; then - GIT_PARENT=$($GIT merge-base "$real_parent" HEAD) + GIT_PARENT=$($GIT merge-base "$real_parent" "$codemgr_head") fi if [[ -z $GIT_PARENT ]]; then print -u2 "Error: Cannot discover parent revision" @@ -2642,18 +2664,27 @@ elif [[ $SCM_MODE == "git" ]]; then pnode=$(trim_digest $GIT_PARENT) - if [[ $real_parent == */* ]]; then + if [[ -n $cflag ]]; then + PRETTY_PWS="previous revision (at ${pnode})" + elif [[ $real_parent == */* ]]; then origin=$(echo $real_parent | cut -d/ -f1) origin=$($GIT remote -v | \ $AWK '$1 == "'$origin'" { print $2; exit }') PRETTY_PWS="${PWS} (${origin} at ${pnode})" + elif [[ -n $pflag && -z $parent_webrev ]]; then + PRETTY_PWS="${CWS} (explicit revision ${pnode})" else PRETTY_PWS="${PWS} (at ${pnode})" fi - cnode=$($GIT --git-dir=${codemgr_ws}/.git rev-parse --short=12 HEAD \ - 2>/dev/null) - PRETTY_CWS="${CWS} (at ${cnode})" + cnode=$($GIT --git-dir=${codemgr_ws}/.git rev-parse --short=12 \ + ${codemgr_head} 2>/dev/null) + + if [[ -n $cflag || -n $hflag ]]; then + PRETTY_CWS="${CWS} (explicit head at ${cnode})" + else + PRETTY_CWS="${CWS} (at ${cnode})" + fi elif [[ $SCM_MODE == "subversion" ]]; then # |