make/scripts/webrev.ksh

changeset 678
26a4456cb19e
parent 643
c641268c4532
child 690
b95c5c8ee60a
     1.1 --- a/make/scripts/webrev.ksh	Mon Apr 01 11:48:01 2013 -0700
     1.2 +++ b/make/scripts/webrev.ksh	Tue Mar 26 13:41:36 2013 -0400
     1.3 @@ -1436,14 +1436,15 @@
     1.4  {
     1.5      rm -f $FLIST
     1.6      if [ -z "$Nflag" ]; then
     1.7 -	print " File list from hg foutgoing $PWS ..."
     1.8 +        print " File list from hg foutgoing $PWS ..."
     1.9          outgoing_from_mercurial_forest
    1.10          HG_LIST_FROM_COMMIT=1
    1.11      fi
    1.12      if [ ! -f $FLIST ]; then
    1.13          # hg commit hasn't been run see what is lying around
    1.14 -	print "\n No outgoing, perhaps you haven't commited."
    1.15 -	print " File list from hg fstatus -mard ...\c"
    1.16 +        print "\n No outgoing, perhaps you haven't commited."
    1.17 +        NO_OUTGOING=
    1.18 +        print " File list from hg fstatus -mard ...\c"
    1.19          FSTAT_OPT=
    1.20          fstatus
    1.21          HG_LIST_FROM_COMMIT=0
    1.22 @@ -1466,7 +1467,7 @@
    1.23      done >> $FLIST
    1.24  
    1.25      # Then all the added files
    1.26 -    # But some of these could have been "moved" or renamed ones
    1.27 +    # But some of these could have been "moved" or renamed ones or copied ones
    1.28      # so let's make sure we get the proper info
    1.29      # hg status -aC will produce something like:
    1.30      #	A subdir/File3
    1.31 @@ -1474,8 +1475,11 @@
    1.32      #	  File4
    1.33      #	A subdir/File5
    1.34      # The first and last are simple addition while the middle one
    1.35 -    # is a move/rename
    1.36 -
    1.37 +    # is a move/rename or a copy.  We can't distinguish from a rename vs a copy
    1.38 +    # without also getting the status of removed files.  The middle case above
    1.39 +    # is a rename if File4 is also shown a being removed.  If File4 is not a 
    1.40 +    # removed file, then the middle case is a copy from File4 to subdir/File4
    1.41 +    # FIXME - we're not distinguishing copy from rename
    1.42      $HGCMD -aC | $FILTER | while read LINE; do
    1.43  	ldone=""
    1.44  	while [ -z "$ldone" ]; do
    1.45 @@ -1625,6 +1629,7 @@
    1.46          else
    1.47              # hg commit hasn't been run see what is lying around
    1.48              print "\n No outgoing, perhaps you haven't commited."
    1.49 +            NO_OUTGOING=
    1.50          fi
    1.51  	# First let's list all the modified or deleted files
    1.52  
    1.53 @@ -1638,8 +1643,12 @@
    1.54  	#	A subdir/File4
    1.55  	#	  File4
    1.56  	#	A subdir/File5
    1.57 -	# The first and last are simple addition while the middle one
    1.58 -	# is a move/rename
    1.59 +        # The first and last are simple addition while the middle one
    1.60 +        # is a move/rename or a copy.  We can't distinguish from a rename vs a copy
    1.61 +        # without also getting the status of removed files.  The middle case above
    1.62 +        # is a rename if File4 is also shown a being removed.  If File4 is not a 
    1.63 +        # removed file, then the middle case is a copy from File4 to subdir/File4
    1.64 +        # FIXME - we're not distinguishing copy from rename
    1.65  
    1.66  	hg status $STATUS_REV -aC | $FILTER >$FLIST.temp
    1.67  	while read LINE; do
    1.68 @@ -1905,7 +1914,7 @@
    1.69  		fi
    1.70  	    fi
    1.71  	else
    1.72 -	    # It's a rename (or a move), so let's make sure we move
    1.73 +	    # It's a rename (or a move), or a copy, so let's make sure we move
    1.74  	    # to the right directory first, then restore it once done
    1.75  	    current_dir=`pwd`
    1.76  	    cd $CWS/$PDIR
    1.77 @@ -2774,34 +2783,38 @@
    1.78  	    cleanse_rmfile="sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'"
    1.79  	    cleanse_newfile="sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'"
    1.80  
    1.81 -	    rm -f $WDIR/$DIR/$F.patch
    1.82 -	    if [[ -z $rename ]]; then
    1.83 -		if [ ! -f $ofile ]; then
    1.84 -		    diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
    1.85 -			> $WDIR/$DIR/$F.patch
    1.86 -		elif [ ! -f $nfile ]; then
    1.87 -		    diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
    1.88 -			> $WDIR/$DIR/$F.patch
    1.89 -		else
    1.90 -		    diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
    1.91 -		fi
    1.92 -	    else
    1.93 -		diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
    1.94 -		    > $WDIR/$DIR/$F.patch
    1.95 -
    1.96 -		diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
    1.97 -		    >> $WDIR/$DIR/$F.patch
    1.98 -
    1.99 -	    fi
   1.100 -
   1.101 -
   1.102 -	#
   1.103 -	# Tack the patch we just made onto the accumulated patch for the
   1.104 -	# whole wad.
   1.105 -	#
   1.106 -	    cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
   1.107 -
   1.108 -	    print " patch\c"
   1.109 +            if [[ -v NO_OUTGOING ]];
   1.110 +            then
   1.111 +              # Only need to generate a patch file here if there are no commits in outgoing
   1.112 +              rm -f $WDIR/$DIR/$F.patch
   1.113 +              if [[ -z $rename ]]; then
   1.114 +                  if [ ! -f $ofile ]; then
   1.115 +                      diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
   1.116 +                          > $WDIR/$DIR/$F.patch
   1.117 +                  elif [ ! -f $nfile ]; then
   1.118 +                      diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
   1.119 +                          > $WDIR/$DIR/$F.patch
   1.120 +                  else
   1.121 +                      diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
   1.122 +                  fi
   1.123 +              else
   1.124 +                  diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
   1.125 +                      > $WDIR/$DIR/$F.patch
   1.126 +
   1.127 +                  diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
   1.128 +                      >> $WDIR/$DIR/$F.patch
   1.129 +
   1.130 +              fi
   1.131 +
   1.132 +
   1.133 +            #
   1.134 +            # Tack the patch we just made onto the accumulated patch for the
   1.135 +            # whole wad.
   1.136 +            #
   1.137 +              cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
   1.138 +            fi
   1.139 +
   1.140 +            print " patch\c"
   1.141  
   1.142  	    if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
   1.143  
   1.144 @@ -2894,6 +2907,32 @@
   1.145  	print
   1.146  done < $FLIST
   1.147  
   1.148 +# Create the new style mercurial patch here using hg export -r [all-revs] -g -o $CHANGESETPATH
   1.149 +if [[ $SCM_MODE == "mercurial" ]]; then
   1.150 +  if [[ !(-v NO_OUTGOING) ]]; then
   1.151 +    EXPORTCHANGESET="$WNAME.changeset"
   1.152 +    CHANGESETPATH=${WDIR}/${EXPORTCHANGESET}
   1.153 +    rm -f $CHANGESETPATH
   1.154 +    touch $CHANGESETPATH
   1.155 +    if [[ -n $ALL_CREV ]]; then
   1.156 +      rev_opt=
   1.157 +      for rev in $ALL_CREV; do
   1.158 +        rev_opt="$rev_opt --rev $rev"
   1.159 +      done
   1.160 +    elif [[ -n $FIRST_CREV ]]; then
   1.161 +      rev_opt="--rev $FIRST_CREV"
   1.162 +    fi
   1.163 +
   1.164 +    if [[ -n $rev_opt ]]; then
   1.165 +      (cd $CWS;hg export -g $rev_opt -o $CHANGESETPATH)
   1.166 +      # echo "Created new-patch: $CHANGESETPATH" 1>&2
   1.167 +      # Use it in place of the jdk.patch created above
   1.168 +      rm -f $WDIR/$WNAME.patch
   1.169 +    fi
   1.170 +  set +x
   1.171 +  fi
   1.172 +fi
   1.173 +
   1.174  frame_nav_js > $WDIR/ancnav.js
   1.175  frame_navigation > $WDIR/ancnav.html
   1.176  
   1.177 @@ -2989,9 +3028,13 @@
   1.178  print "</td></tr>"
   1.179  
   1.180  if [[ -f $WDIR/$WNAME.patch ]]; then
   1.181 -	print "<tr><th>Patch of changes:</th><td>"
   1.182 -	print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
   1.183 +  print "<tr><th>Patch of changes:</th><td>"
   1.184 +  print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
   1.185 +elif [[ -f $CHANGESETPATH ]]; then
   1.186 +  print "<tr><th>Changeset:</th><td>"
   1.187 +  print "<a href=\"$EXPORTCHANGESET\">$EXPORTCHANGESET</a></td></tr>"
   1.188  fi
   1.189 +
   1.190  if [[ -f $WDIR/$WNAME.pdf ]]; then
   1.191  	print "<tr><th>Printable review:</th><td>"
   1.192  	print "<a href=\"$WNAME.pdf\">$WNAME.pdf</a></td></tr>"

mercurial