source: trunk/CVSROOT/logfilter.pl @ 13253

Revision 13253, 1.9 KB checked in by ghudson, 25 years ago (diff)
Use the right variable name for new files. (Missed this in testing.)
  • Property svn:executable set to *
Line 
1#!/usr/athena/bin/perl
2
3# Usage (with CVS 1.10 loginfo):
4#       logfilter %{sVv} commit-address diff-adddress
5
6# Mails the CVS commit log to commit-address.  Also mails the commit
7# log to diff-address, followed by context diffs of the modified
8# files.
9
10# This script is not specific to any particular repository, but it is
11# specific to the Athena environment in that it assumes the existence
12# of /usr/athena/bin/perl.
13
14$sendmail = ( -x "/usr/sbin/sendmail") ? "/usr/sbin/sendmail"
15    : "/usr/lib/sendmail";
16
17# Create subject line (derive %s from %{sVv}).  $ARGV[0] is of the
18# form "dir filename,oldrev,newrev ..."; what we want is
19#  "dir filename ..."
20@files = split(/ /, $ARGV[0]);
21$dir = shift @files;
22map { s/,.*// } @files;
23$subject = $dir . " " . join(' ', @files);
24
25open(COMMITMAIL, "|$sendmail $ARGV[1]");
26print COMMITMAIL "To: $ARGV[1]\n";
27print COMMITMAIL "Subject: $subject\n\n";
28
29open(DIFFMAIL, "|$sendmail $ARGV[2]");
30print DIFFMAIL "To: $ARGV[2]\n";
31print DIFFMAIL "Subject: $subject\n\n";
32
33# Display the commit log as proffered by CVS.  Remember the repository
34# directory.
35while (<STDIN>) {
36        if (/^Update of (.*)$/) {
37                $repdir = $1;
38        }
39        print COMMITMAIL;
40        print DIFFMAIL;
41}
42
43close COMMITMAIL;
44
45# Display diffs.  $ARGV[0] is of the form "dir filename,oldrev,newrev ...".
46@files = split(/ /, $ARGV[0]);
47$dir = shift @files;
48foreach (@files) {
49        ($file, $old, $new) = split(/,/);
50        if ($new eq "NONE") {
51                next;
52        }
53        print DIFFMAIL "\n";
54        print DIFFMAIL "==================================================\n";
55        if ($old eq "NONE") {
56                print DIFFMAIL "Initial contents of new file $file\n";
57                $cmd = "diff -c /dev/null $file";
58        } else {
59                print DIFFMAIL "Differences for $file ";
60                print DIFFMAIL "(revision $old -> $new)\n";
61                $rcsfile = "$repdir/$file";
62                $cmd ="rcsdiff -c -kk -r$old -r$new $rcsfile 2>/dev/null";
63        }
64        print DIFFMAIL "==================================================\n";
65        open(DIFF, "$cmd|");
66        print DIFFMAIL while (<DIFF>);
67        close DIFF;
68}
69
70close DIFFMAIL;
Note: See TracBrowser for help on using the repository browser.