[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; |
---|
| 22 | map { s/,.*// } @files; |
---|
| 23 | $subject = $dir . " " . join(' ', @files); |
---|
| 24 | |
---|
[10619] | 25 | open(COMMITMAIL, "|$sendmail $ARGV[1]"); |
---|
| 26 | print COMMITMAIL "To: $ARGV[1]\n"; |
---|
[13241] | 27 | print COMMITMAIL "Subject: $subject\n\n"; |
---|
[10619] | 28 | |
---|
| 29 | open(DIFFMAIL, "|$sendmail $ARGV[2]"); |
---|
[13241] | 30 | print DIFFMAIL "To: $ARGV[2]\n"; |
---|
| 31 | print DIFFMAIL "Subject: $subject\n\n"; |
---|
[10619] | 32 | |
---|
[8760] | 33 | # Display the commit log as proffered by CVS. Remember the repository |
---|
[13241] | 34 | # directory. |
---|
[8760] | 35 | while (<STDIN>) { |
---|
| 36 | if (/^Update of (.*)$/) { |
---|
| 37 | $repdir = $1; |
---|
| 38 | } |
---|
[13241] | 39 | print COMMITMAIL; |
---|
| 40 | print DIFFMAIL; |
---|
[8760] | 41 | } |
---|
| 42 | |
---|
[8818] | 43 | close 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; |
---|
| 48 | foreach (@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] | 70 | close DIFFMAIL; |
---|