diff options
Diffstat (limited to 'Build/tools/p4changelog')
-rwxr-xr-x | Build/tools/p4changelog | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Build/tools/p4changelog b/Build/tools/p4changelog new file mode 100755 index 00000000000..558dc274ec1 --- /dev/null +++ b/Build/tools/p4changelog @@ -0,0 +1,89 @@ +#!/bin/sh +# $Id$ +# Public domain. Originally written 2004, Karl Berry. +# Get change info from p4 describe and p4 changes. + +umask 0 + +debug=${OVERRIDE_DEBUG-false} + +mydir=`dirname $0` # Master/Tools +outdir=`cd $mydir/../../Build/cdbuild/logs && pwd` +outfile=$outdir/log + +line=`grep '^Change' $outfile | head -1` +lastlogged=`echo "$line" | awk '{print $2}'` +echo "$lastlogged" | egrep '^[0-9]+$' >/dev/null \ +|| { echo "$0: no change number in Change line of $outfile: $line"; + exit 1; } +nextneeded=`expr $lastlogged + 1` +lastchange=`p4 changes -m 1 -s submitted | awk '{print $2}'` + +echo "lastlogged=$lastlogged, nextneeded=$nextneeded, lastchange=$lastchange" + +# nothing submitted since last change? +test $lastchange -lt $nextneeded && exit 0 + +rotate=false +for c in `seq $lastchange -1 $nextneeded`; do + echo " getting change $c" + # rotate if crossed a 500-change mark. + echo $c | grep '[05]00$' >/dev/null && rotate=true + + p4 describe -ds $c 2>&1 \ + | sed -e 's,^\.\.\. //depot/, ,' -e '/^Differences/,$d' \ + | awk '/^Affected files/ { printf "%s", $0; next } {print}' \ + >>$outfile.temp +done + +# we'll update $outfile. +echo "p4 edit $outfile..." +$debug || p4 edit $outfile + +if $rotate; then + echo "rotating $lastlogged..." + mv $outfile $outfile.$lastlogged + gzip $outfile.$lastlogged + chmod 444 $outfile.$lastlogged.gz + ls -l $outfile.$lastlogged.gz + $debug || p4 add $outfile.$lastlogged.gz + cp /dev/null $outfile +fi + +# prepend new changes to current log, put into p4. +cat $outfile.temp $outfile >$outfile.temp2 + +if $debug; then + for f in $outfile $outfile.temp $outfile.temp2; do + echo + (cd `dirname $f` && ls -l `basename $f`) + head -1 $f + grep '^Change' $f | tail -1 + done + + exit 0 +fi + +mv $outfile.temp2 $outfile +echo "p4 submit..." +p4 change -o \ +| sed "s!<enter description here>!regenerated by $0!" \ +| p4 submit -i + +cat $outfile.temp # show it to me +rm -f $outfile.temp + +exit 0 + +# this was how we grabbed all the old entries to get things started. +for c in `seq 5150 -1 1`; do + expr $c % 500 >/dev/null \ + || { outfile=$outdir/out.$c; cp /dev/null $outfile; } + + # minimal diff, remove even that (hunk counts) with sed, + # remove newline from "Affected files" line. + p4 describe -ds $c 2>&1 \ + | sed -e 's,^\.\.\. //depot/, ,' -e '/^Differences/,$d' \ + | awk '/^Affected files/ { printf "%s", $0; next } {print}' \ + >>$outfile +done |