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