You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Mathias Weinert <ma...@gfa-net.de> on 2006/01/19 10:24:25 UTC

[PATCH] mailer.py

As already mentioned earlier I want to provide some new features
to mailer.py. In preparation of this I will step by step send
some smaller patches first (thank you maxb for applying the
latter ones!).

Mathias

[[[
* tools/hook-scripts/mailer/mailer.py
  - typo corrected
  - mailer.conf now has a format number to be able to change existing configuration options (not used yet)

* tools/hook-scripts/mailer/mailer.conf.example
  - new option 'conf_format' to determine the version of the config file
  - some textual corrections
  - deprectaed option 'suppress_deletes' set to comment as default
  - second example for maps added
]]]

--- tools/hook-scripts/mailer/mailer.py.orig	2006-01-19 09:36:38.000000000 +0100
+++ tools/hook-scripts/mailer/mailer.py	2006-01-19 11:04:55.018624100 +0100
@@ -244,7 +244,7 @@
 
 
 class PipeOutput(MailedOutput):
-  "Deliver a mail message to an MDA via a pipe."
+  "Deliver a mail message to an MTA via a pipe."
 
   def __init__(self, cfg, repos, prefix_param):
     MailedOutput.__init__(self, cfg, repos, prefix_param)
@@ -541,6 +541,10 @@
     self.modify = False
 
     gen_diffs = cfg.get('generate_diffs', group, params)
+    if cfg.is_set('general.conf_format'):
+      conf_format = cfg.general.conf_format
+    else:
+      conf_format = 1
 
     ### Do a little dance for deprecated options.  Note that even if you
     ### don't have an option anywhere in your configuration file, it
@@ -572,6 +576,11 @@
 
 class DiffURLSelections:
   def __init__(self, cfg, group):
+    if cfg.is_set('general.conf_format'):
+      conf_format = cfg.general.conf_format
+    else:
+      conf_format = 1
+
     self.add = cfg.get('diff_add_url', group, None)
     self.copy = cfg.get('diff_copy_url', group, None)
     self.delete = cfg.get('diff_delete_url', group, None)
--- tools/hook-scripts/mailer/mailer.conf.example.orig	2005-04-15 16:37:19.000000000 +0200
+++ tools/hook-scripts/mailer/mailer.conf.example	2006-01-19 11:05:50.096749100 +0100
@@ -8,6 +8,11 @@
 # The [general].diff option is now DEPRECATED.
 # Instead use [defaults].diff .
 
+# This option is used to determine which version of this conf file
+# is being to used in order to be backward compatible.
+# The formerly used format is used if this option is set to 1 or nothing.
+conf_format = 2
+
 #
 # One delivery method must be chosen. mailer.py will prefer using the
 # "mail_command" option. If that option is empty or commented out,
@@ -20,10 +25,10 @@
 # line, and the message piped into it.
 #mail_command = /usr/sbin/sendmail
 
-# This option specifies the hostname for delivery via SMTP
+# This option specifies the hostname for delivery via SMTP.
 #smtp_hostname = localhost
 
-# Username and password for SMTP servers requiring authorisation
+# Username and password for SMTP servers requiring authorisation.
 #smtp_username = example
 #smtp_password = example
 
@@ -139,19 +144,19 @@
 
 # This is not passed to the shell, so do not use shell metacharacters.
 # The command is split around whitespace, so if you want to include
-# whitespace in the command, then ### something ###
+# whitespace in the command, then ### something ###.
 diff = /usr/bin/diff -u -L %(label_from)s -L %(label_to)s %(from)s %(to)s
 
-# The default prefix for the Subject: header for commits
+# The default prefix for the Subject: header for commits.
 commit_subject_prefix =
 
-# The default prefix for the Subject: header for propchanges
+# The default prefix for the Subject: header for propchanges.
 propchange_subject_prefix =
 
-# The default prefix for the Subject: header for locks
+# The default prefix for the Subject: header for locks.
 lock_subject_prefix =
 
-# The default prefix for the Subject: header for unlocks
+# The default prefix for the Subject: header for unlocks.
 unlock_subject_prefix =
 
 
@@ -169,14 +174,14 @@
 # separated by whitespace (no commas):
 to_addr = invalid@example.com
 
-# If this is set, then a Reply-To: will be inserted into the message
+# If this is set, then a Reply-To: will be inserted into the message.
 reply_to =
 
 # When set to one or more of the valid options, the mailer will create
 # diffs for the corresponding types of changes in the repository.  If
-# no options are given, or if any invalid options are given, no diffs
-# will be created.  Note that the operation is always mentioned in the
-# message header, regardless of this option's value.
+# no options are given, no diffs will be created.  Note that the
+# operation is always mentioned in the message header, regardless of
+# this option's value.
 #
 # Valid options: add copy modify delete
 generate_diffs = add copy modify
@@ -198,7 +203,7 @@
 # deletion is always mentioned in the message header, regardless of this
 # option's value.
 ### DEPRECATED (if generate_diffs is not empty, this option is ignored)
-suppress_deletes = yes
+#suppress_deletes = yes
 
 # When set to "yes", the mailer will suppress the creation of a diff which
 # adds all the lines in the file. If this is set to anything else, or
@@ -257,7 +262,7 @@
 #
 
 #
-# EXAMPLE:
+# EXAMPLE 1:
 #
 # We have two projects using two repositories. The name of the repos
 # does not easily map to their commit mailing lists, so we will use
@@ -283,6 +288,32 @@
 # tx = hotness-commits@example.com
 #
 
+#
+# EXAMPLE 2:
+#
+# We want to map the complete repository path to a name which shall
+# be used for the commit subject prefix. This may be used e. g. if
+# one config file is used for some different repositories.
+# In order to be able to also use this for windows paths we do a
+# 'little trick' to elimante the colon ':' from the path.
+# Please note the missing colon in the second repository path.
+# The third one may be the resulting repository path under cygwin
+# (again with the colon eliminated).
+#
+#[defaults]
+#for_repos = (?P<repospath_1>[^:]*):?(?P<repospath_2>[^:]*)
+#commit_subject_prefix = %(repospath_1)s%(repospath_2)s
+#
+#[maps]
+#commit_subject_prefix = [repositories]
+#
+#[repositories]
+#/usr/svn/repos = Linux repository:
+#d/Subversion/repos = Windows repository:
+#/d/Subversion/d/Subversion/repos = Windows repository:
+#
+
+
 # --------------------------------------------------------------------------
 
 #

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] mailer.py

Posted by Greg Stein <gs...@lyra.org>.
On Thu, Jan 19, 2006 at 11:24:25AM +0100, Mathias Weinert wrote:
>...
> [[[
> * tools/hook-scripts/mailer/mailer.py
>   - typo corrected
>   - mailer.conf now has a format number to be able to change existing configuration options (not used yet)

I don't think a format number is required. Just use new names rather
than redefine existing names. You could also auto-convert old options
into the new options. It's a lot simpler to just have the necessary
options and omit any notion of a format/version.

>...
>   - deprectaed option 'suppress_deletes' set to comment as default
>   - second example for maps added

Cool!

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] mailer.py

Posted by Max Bowsher <ma...@ukf.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mathias Weinert wrote:
> As already mentioned earlier I want to provide some new features
> to mailer.py. In preparation of this I will step by step send
> some smaller patches first (thank you maxb for applying the
> latter ones!).
> 
> Mathias
> 
> [[[
> * tools/hook-scripts/mailer/mailer.py
>   - typo corrected

Thanks, committed.

>   - mailer.conf now has a format number to be able to change existing configuration options (not used yet)

Without the context of what future use you want to put this option to,
it is impossible to form an opinion on whether it is the right thing to
do. Hence, not committed now - please provide further info.

> * tools/hook-scripts/mailer/mailer.conf.example
>   - new option 'conf_format' to determine the version of the config file

Same as before.

>   - some textual corrections

Thanks, committed. (Except the one about generate_diffs, which changed
one incorrect statement into a different incorrect statement - I'll
rewrite that block of text now.)

>   - deprectaed option 'suppress_deletes' set to comment as default

Thanks, committed.

>   - second example for maps added
> ]]]
...
> +#
> +# EXAMPLE 2:
> +#
> +# We want to map the complete repository path to a name which shall
> +# be used for the commit subject prefix. This may be used e. g. if
> +# one config file is used for some different repositories.
> +# In order to be able to also use this for windows paths we do a
> +# 'little trick' to elimante the colon ':' from the path.
> +# Please note the missing colon in the second repository path.
> +# The third one may be the resulting repository path under cygwin
> +# (again with the colon eliminated).
> +#
> +#[defaults]
> +#for_repos = (?P<repospath_1>[^:]*):?(?P<repospath_2>[^:]*)
> +#commit_subject_prefix = %(repospath_1)s%(repospath_2)s
> +#
> +#[maps]
> +#commit_subject_prefix = [repositories]
> +#
> +#[repositories]
> +#/usr/svn/repos = Linux repository:
> +#d/Subversion/repos = Windows repository:
> +#/d/Subversion/d/Subversion/repos = Windows repository:
> +#

This example is essentially a repeat of the existing one, but:
* for commit_subject_prefix instead of from_addr/to_addr.
* demonstrating the 'little trick'

Whilst I agree some explicit mention of the limitations of configuration
keys might be appropriate in the [maps] documentation, I feel that this
situation is perhaps a little too special-case for the example config file.

Very many sites ought to be able to achieve the same ends with less
complication by just matching the last one or two path elements from the
repository path.


Max.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDz63PfFNSmcDyxYARAj0zAKDG36kanndLuOFpyYHUBbPCiVgaJQCgmlHM
lnfqPKrW4KOaalpEBKqzj+s=
=1IkF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org