[vhffs-dev] [1608] Added notify hook for Mercurial repositories.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1608
Author:   guillaumito
Date:     2010-05-28 10:31:03 +0200 (Fri, 28 May 2010)
Log Message:
-----------
Added notify hook for Mercurial repositories.
This send a mail for each group of changes (not for each commit).
It works by copying a template to the repo config dir and replacing
  the "from" and "to" addresses.

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
    trunk/vhffs-robots/Makefile.am

Added Paths:
-----------
    trunk/vhffs-robots/misc/mercurial_notify.rc

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2010-05-13 13:31:42 UTC (rev 1607)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2010-05-28 08:31:03 UTC (rev 1608)
@@ -85,6 +85,22 @@
 	my $mail_from = $mercurial->get_main->get_config->get_service('mercurial')->{notify_from};
 
 	if( $mercurial->get_ml_name !~ /^\s*$/ ) {
+		# Create the rc file
+		open( my $rcfilein , "< ", "%VHFFS_BOTS_DIR%/misc/mercurial_notify.rc" );
+		open( my $rcfileout , "> ", $dir . '/.hg/hgrc' );
+
+		my $mladdress = $mercurial->{ml_name};
+		
+		while( my $line = <$rcfilein> )
+		{
+			$line =~ s/MY_MLADDRESS/$mladdress/g;
+			$line =~ s/MY_FROMADDRESS/$mail_from/g;
+			
+			print $rcfileout $line;
+		}
+		
+		close( $rcfileout );
+		close( $rcfilein );
 	}
 
 	return 0;

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2010-05-13 13:31:42 UTC (rev 1607)
+++ trunk/vhffs-robots/Makefile.am	2010-05-28 08:31:03 UTC (rev 1608)
@@ -14,7 +14,8 @@
 	misc/svn_viewvc.conf.tmpl \
 	misc/mhonarc.config \
 	misc/mhonarc.indexmain.tmpl \
-	misc/mhonarc.indexpart.tmpl
+	misc/mhonarc.indexpart.tmpl \
+	misc/mercurial_notify.rc
 
 nobase_dist_bots_SCRIPTS = \
 	misc/svn_post-commit.pl \

Added: trunk/vhffs-robots/misc/mercurial_notify.rc
===================================================================
--- trunk/vhffs-robots/misc/mercurial_notify.rc	                        (rev 0)
+++ trunk/vhffs-robots/misc/mercurial_notify.rc	2010-05-28 08:31:03 UTC (rev 1608)
@@ -0,0 +1,26 @@
+[smtp]
+host=localhost
+
+[hooks]
+# send one email per group of changes
+changegroup.notify = python:hgext.notify.hook
+
+[email]
+from = MY_FROMADDRESS
+
+[notify]
+# really send email
+test = false
+# send mail for any kind of source
+sources = serve push pull bundle
+# repos live in /data/mercurial/ on server, so strip 3 "/" chars
+strip = 3
+# don't include diff
+maxdiff = 0
+template =
+  Changeset: {node|short}
+  Author: {author}
+  Description: {desc|tabindent|strip}\n
+
+[reposubs]
+* = MY_MLADDRESS


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/