Hi,

I got a huge number of complaints when I recently checked in some generated
files to CVS recently (namely web-pages). The diffs caused large mails to
be sent out and annoy everyone :)

So I had a look at CVSROOT and it seems that log_accum.pl is the place to
"fix" this. What I want to do is have per-repository exlcude regexs that
exclude diffs being sent out in mails. Unfortunately it is written in perls
(which I don't know well) so I could of stuffed it up. I have attached a
diff that will alter log_accum.pl so that you can add in excludes per
repository. 

So you create a directory /home/cvs/CVSROOT/excludes/ and in it place files
named after repository. Each file has one line which is the exclude
pattern. So an example would be to create file

/home/cvs/CVSROOT/excludes/jakarta-avalon
---
^www
---

which would exclude all files in www directory from CVS diffs. 

Can someone check my lame perl mods ;) and make sure it does what I think
it does. And if so is there any objections to something like this and
should I ask root/Brian to apply it ?




--- /home/cvs/CVSROOT/log_accum.pl      Thu Mar  1 17:19:28 2001
+++ log_accum.pl        Fri Mar  2 18:01:12 2001
@@ -150,8 +150,8 @@

     open(FILE, "<$filename") || die ("Cannot open log file $filename: $!\n");
     while (<FILE>) {
-       chomp;
-       push(@text, $leader.$_);
+       chomp;
+       push(@text, $leader.$_);
     }
     close(FILE);
     @text;
@@ -216,6 +216,14 @@
        if (($file =~ /\.(?:pdf|gif|jpg|mpg)$/i) || (-B $file)) {
            $diff .= "\t<<Binary file>>\n\n";
        }
+       elsif( defined($exclude_pattern)&&($file =~ /$exclude_pattern/i) ) {
+          #
+          # If the file matches the pattern used to exclude diffs
+           # then exclude it.
+          # The pattern is loaded in differently for each repository.
+          #
+           print( "\t<<Excluded>>\n\n" );
+       }
        else {
            #
            # Get the differences between this and the previous revision,
@@ -304,6 +312,17 @@
     close(MAIL);
 }

+sub read_pattern {
+    local($filename) = @_;
+    local(@text) = ();
+
+    open(FILE, "<$filename") || return ();
+    $text = <FILE>;
+    chomp($text);
+    close(FILE);
+    $text;
+}
+
 #############################################################
 #
 # Main Body
@@ -327,6 +346,14 @@
     $dir = ".";
 } else {
     $dir = join('/', @path[1..$#path]);
+}
+
+#
+# Read in pattern of files to exclude diff commit messages
+#
+$exclude_pattern = &read_pattern("exclude/$repository");
+if (defined($exclude_pattern)) {
+    print("Excluding: '$exclude_pattern' from commit diffs\n" );
 }

 #

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to