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 *
RevLine 
[8760]1#!/usr/athena/bin/perl
2
[13241]3# Usage (with CVS 1.10 loginfo):
4#       logfilter %{sVv} commit-address diff-adddress
[8760]5
[13241]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.
[8818]9
[8760]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
[10623]12# of /usr/athena/bin/perl.
[8760]13
[10619]14$sendmail = ( -x "/usr/sbin/sendmail") ? "/usr/sbin/sendmail"
15    : "/usr/lib/sendmail";
[8760]16
[13241]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
[10619]25open(COMMITMAIL, "|$sendmail $ARGV[1]");
26print COMMITMAIL "To: $ARGV[1]\n";
[13241]27print COMMITMAIL "Subject: $subject\n\n";
[10619]28
29open(DIFFMAIL, "|$sendmail $ARGV[2]");
[13241]30print DIFFMAIL "To: $ARGV[2]\n";
31print DIFFMAIL "Subject: $subject\n\n";
[10619]32
[8760]33# Display the commit log as proffered by CVS.  Remember the repository
[13241]34# directory.
[8760]35while (<STDIN>) {
36        if (/^Update of (.*)$/) {
37                $repdir = $1;
38        }
[13241]39        print COMMITMAIL;
40        print DIFFMAIL;
[8760]41}
42
[8818]43close COMMITMAIL;
44
[13241]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;
[8760]52        }
[8818]53        print DIFFMAIL "\n";
54        print DIFFMAIL "==================================================\n";
[13241]55        if ($old eq "NONE") {
56                print DIFFMAIL "Initial contents of new file $file\n";
[13253]57                $cmd = "diff -c /dev/null $file";
[13241]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        }
[8818]64        print DIFFMAIL "==================================================\n";
[13241]65        open(DIFF, "$cmd|");
[8818]66        print DIFFMAIL while (<DIFF>);
[8760]67        close DIFF;
68}
69
[8818]70close DIFFMAIL;
Note: See TracBrowser for help on using the repository browser.