@@ -1436,14 +1436,15 @@ function flist_from_mercurial_forest
14361436{
14371437 rm -f $FLIST
14381438 if [ -z " $Nflag " ]; then
1439- print " File list from hg foutgoing $PWS ..."
1439+ print " File list from hg foutgoing $PWS ..."
14401440 outgoing_from_mercurial_forest
14411441 HG_LIST_FROM_COMMIT=1
14421442 fi
14431443 if [ ! -f $FLIST ]; then
14441444 # hg commit hasn't been run see what is lying around
1445- print " \n No outgoing, perhaps you haven't commited."
1446- print " File list from hg fstatus -mard ...\c"
1445+ print " \n No outgoing, perhaps you haven't commited."
1446+ NO_OUTGOING=
1447+ print " File list from hg fstatus -mard ...\c"
14471448 FSTAT_OPT=
14481449 fstatus
14491450 HG_LIST_FROM_COMMIT=0
@@ -1466,16 +1467,19 @@ function treestatus
14661467 done >> $FLIST
14671468
14681469 # Then all the added files
1469- # But some of these could have been "moved" or renamed ones
1470+ # But some of these could have been "moved" or renamed ones or copied ones
14701471 # so let's make sure we get the proper info
14711472 # hg status -aC will produce something like:
14721473 # A subdir/File3
14731474 # A subdir/File4
14741475 # File4
14751476 # A subdir/File5
14761477 # The first and last are simple addition while the middle one
1477- # is a move/rename
1478-
1478+ # is a move/rename or a copy. We can't distinguish from a rename vs a copy
1479+ # without also getting the status of removed files. The middle case above
1480+ # is a rename if File4 is also shown a being removed. If File4 is not a
1481+ # removed file, then the middle case is a copy from File4 to subdir/File4
1482+ # FIXME - we're not distinguishing copy from rename
14791483 $HGCMD -aC | $FILTER | while read LINE; do
14801484 ldone=" "
14811485 while [ -z " $ldone " ]; do
@@ -1625,6 +1629,7 @@ function flist_from_mercurial
16251629 else
16261630 # hg commit hasn't been run see what is lying around
16271631 print " \n No outgoing, perhaps you haven't commited."
1632+ NO_OUTGOING=
16281633 fi
16291634 # First let's list all the modified or deleted files
16301635
@@ -1638,8 +1643,12 @@ function flist_from_mercurial
16381643 # A subdir/File4
16391644 # File4
16401645 # A subdir/File5
1641- # The first and last are simple addition while the middle one
1642- # is a move/rename
1646+ # The first and last are simple addition while the middle one
1647+ # is a move/rename or a copy. We can't distinguish from a rename vs a copy
1648+ # without also getting the status of removed files. The middle case above
1649+ # is a rename if File4 is also shown a being removed. If File4 is not a
1650+ # removed file, then the middle case is a copy from File4 to subdir/File4
1651+ # FIXME - we're not distinguishing copy from rename
16431652
16441653 hg status $STATUS_REV -aC | $FILTER > $FLIST .temp
16451654 while read LINE; do
@@ -1905,7 +1914,7 @@ function build_old_new_mercurial
19051914 fi
19061915 fi
19071916 else
1908- # It's a rename (or a move), so let's make sure we move
1917+ # It's a rename (or a move), or a copy, so let's make sure we move
19091918 # to the right directory first, then restore it once done
19101919 current_dir=` pwd`
19111920 cd $CWS /$PDIR
@@ -2774,34 +2783,38 @@ do
27742783 cleanse_rmfile=" sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'"
27752784 cleanse_newfile=" sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'"
27762785
2777- rm -f $WDIR /$DIR /$F .patch
2778- if [[ -z $rename ]]; then
2779- if [ ! -f $ofile ]; then
2780- diff -u /dev/null $nfile | sh -c " $cleanse_newfile " \
2781- > $WDIR /$DIR /$F .patch
2782- elif [ ! -f $nfile ]; then
2783- diff -u $ofile /dev/null | sh -c " $cleanse_rmfile " \
2784- > $WDIR /$DIR /$F .patch
2785- else
2786- diff -u $ofile $nfile > $WDIR /$DIR /$F .patch
2787- fi
2788- else
2789- diff -u $ofile /dev/null | sh -c " $cleanse_rmfile " \
2790- > $WDIR /$DIR /$F .patch
2791-
2792- diff -u /dev/null $nfile | sh -c " $cleanse_newfile " \
2793- >> $WDIR /$DIR /$F .patch
2794-
2795- fi
2786+ if [[ -v NO_OUTGOING ]];
2787+ then
2788+ # Only need to generate a patch file here if there are no commits in outgoing
2789+ rm -f $WDIR /$DIR /$F .patch
2790+ if [[ -z $rename ]]; then
2791+ if [ ! -f $ofile ]; then
2792+ diff -u /dev/null $nfile | sh -c " $cleanse_newfile " \
2793+ > $WDIR /$DIR /$F .patch
2794+ elif [ ! -f $nfile ]; then
2795+ diff -u $ofile /dev/null | sh -c " $cleanse_rmfile " \
2796+ > $WDIR /$DIR /$F .patch
2797+ else
2798+ diff -u $ofile $nfile > $WDIR /$DIR /$F .patch
2799+ fi
2800+ else
2801+ diff -u $ofile /dev/null | sh -c " $cleanse_rmfile " \
2802+ > $WDIR /$DIR /$F .patch
2803+
2804+ diff -u /dev/null $nfile | sh -c " $cleanse_newfile " \
2805+ >> $WDIR /$DIR /$F .patch
2806+
2807+ fi
27962808
27972809
2798- #
2799- # Tack the patch we just made onto the accumulated patch for the
2800- # whole wad.
2801- #
2802- cat $WDIR /$DIR /$F .patch >> $WDIR /$WNAME .patch
2810+ #
2811+ # Tack the patch we just made onto the accumulated patch for the
2812+ # whole wad.
2813+ #
2814+ cat $WDIR /$DIR /$F .patch >> $WDIR /$WNAME .patch
2815+ fi
28032816
2804- print " patch\c"
2817+ print " patch\c"
28052818
28062819 if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
28072820
@@ -2894,6 +2907,32 @@ do
28942907 print
28952908done < $FLIST
28962909
2910+ # Create the new style mercurial patch here using hg export -r [all-revs] -g -o $CHANGESETPATH
2911+ if [[ $SCM_MODE == " mercurial" ]]; then
2912+ if [[ ! (-v NO_OUTGOING) ]]; then
2913+ EXPORTCHANGESET=" $WNAME .changeset"
2914+ CHANGESETPATH=${WDIR} /${EXPORTCHANGESET}
2915+ rm -f $CHANGESETPATH
2916+ touch $CHANGESETPATH
2917+ if [[ -n $ALL_CREV ]]; then
2918+ rev_opt=
2919+ for rev in $ALL_CREV ; do
2920+ rev_opt=" $rev_opt --rev $rev "
2921+ done
2922+ elif [[ -n $FIRST_CREV ]]; then
2923+ rev_opt=" --rev $FIRST_CREV "
2924+ fi
2925+
2926+ if [[ -n $rev_opt ]]; then
2927+ (cd $CWS ; hg export -g $rev_opt -o $CHANGESETPATH )
2928+ # echo "Created new-patch: $CHANGESETPATH" 1>&2
2929+ # Use it in place of the jdk.patch created above
2930+ rm -f $WDIR /$WNAME .patch
2931+ fi
2932+ set +x
2933+ fi
2934+ fi
2935+
28972936frame_nav_js > $WDIR /ancnav.js
28982937frame_navigation > $WDIR /ancnav.html
28992938
@@ -2989,9 +3028,13 @@ printCI $TOTL $TINS $TDEL $TMOD $TUNC
29893028print " </td></tr>"
29903029
29913030if [[ -f $WDIR /$WNAME .patch ]]; then
2992- print " <tr><th>Patch of changes:</th><td>"
2993- print " <a href=\" $WNAME .patch\" >$WNAME .patch</a></td></tr>"
3031+ print " <tr><th>Patch of changes:</th><td>"
3032+ print " <a href=\" $WNAME .patch\" >$WNAME .patch</a></td></tr>"
3033+ elif [[ -f $CHANGESETPATH ]]; then
3034+ print " <tr><th>Changeset:</th><td>"
3035+ print " <a href=\" $EXPORTCHANGESET \" >$EXPORTCHANGESET </a></td></tr>"
29943036fi
3037+
29953038if [[ -f $WDIR /$WNAME .pdf ]]; then
29963039 print " <tr><th>Printable review:</th><td>"
29973040 print " <a href=\" $WNAME .pdf\" >$WNAME .pdf</a></td></tr>"
0 commit comments