summaryrefslogtreecommitdiff
path: root/Build/tools/svnchangelog
blob: 55bb08544a3d01440ce9570e9dfad4fe972bac7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# $Id$
# Public domain.  Originally written 2004, Karl Berry.
# Get change info from svn log.  (see now-deleted p4changelog for the
# previous code using p4.)

umask 0

debug=true
chicken=${OVERRIDE_CHICKEN-false}

# to get started, ran svn log and put the first thousand changes in log.

mydir=`dirname $0` # Build/tools
outdir=`cd $mydir/../cdbuild/logs && pwd`
outfile=$outdir/svnlog

# get the revision number we last logged
line=`grep '^r[0-9]' $outfile | head -1 | sed 's/^r//'`
lastlogged=`echo "$line" | awk '{print $1}'`
echo "$lastlogged" | egrep '^[0-9]+$' >/dev/null \
|| { echo "$0: no change number in r line of $outfile: $line"; 
     exit 1; }

nextneeded=`expr $lastlogged + 1`
$debug && echo "lastlogged=$lastlogged, nextneeded=$nextneeded"
if test -z "$nextneeded"; then
  echo "$0: empty nextneeded?!"
  exit 1
fi

# get the log info since then.
tlroot=`cd $mydir/../.. && pwd`
newlogs=$outdir/newlogdata
svn log -v -r HEAD:$nextneeded $tlroot >$newlogs || exit 1
# with HEAD:next we get the entries newest first, as we want them.
$debug && ls -l $newlogs

line=`grep '^r[0-9]* |' $newlogs | head -1 | sed 's/^r//'`
latestchange=`echo "$line" | awk '{print $1}'`
$debug && echo "latestchange=$latestchange"
if test -z "$latestchange"; then
  echo "$0: empty latestchange?!"
  exit 1
fi

# done if nothing submitted since last change.
# or if only one commit has been made, because we ourselves do a commit,
# so otherwise we'd add a useless entry every time we're run.
test $latestchange -le $nextneeded && exit 0

# rotate logs if crossed a 1000-change mark.
rotate=false
for c in `seq $latestchange -1 $nextneeded`; do
  echo $c | grep '001$' >/dev/null && rotate=true
done
$debug && echo "rotate=$rotate"

if ! $chicken && $rotate; then
  mv -v $outfile $outfile.$lastlogged
  gzip -v $outfile.$lastlogged
  chmod 444 $outfile.$lastlogged.gz
  ls -l $outfile.$lastlogged.gz
  svn add $outfile.$lastlogged.gz
  cp /dev/null $outfile
fi

# prepend new changes to current log, and put log messages first.
$mydir/svnchangelog.sed $newlogs >$outfile.new
cat $outfile >>$outfile.new

if $debug; then  # really debug
  # show first and last change number in each file.
  for f in $newlogs $outfile $outfile.new; do
    echo
    (cd `dirname $f` && ls -l `basename $f`)
    grep '^r[0-9]* |' $f | head -1
    grep '^r[0-9]* |' $f | tail -1
  done
fi


if ! $chicken; then
  mv $outfile.new $outfile
  echo "svn commit..."
  svn commit -m"regenerated by $0" $outdir
fi

$mydir/svnchangelog.sed $newlogs  # show it to me
rm -f $newlogs $outfile.new

exit 0

# to get things started:
svn log -v -r 1000:1 /home/texlive/trunk/ >svnlog
svn add svnlog