I already sent a newer patch to the list, with more fixes based on
comments by Michael and Ben. Attaching the new patch here again just
in case.
On Sun, Jan 27, 2013 at 9:06 AM, Daniel Shahaf <[email protected]> wrote:
> Forwarding back to the list
> (@Janos I'll have a look later when I check my svn-dev mailbox, rather
> than my personal one)
>
> ----- Forwarded message from Janos Gyerik <[email protected]> -----
>
>> From: Janos Gyerik <[email protected]>
>> Subject: Re: [PATCH] minor change to mailer.py for subject formatting
>> To: Daniel Shahaf <[email protected]>
>> Date: Sat, 26 Jan 2013 21:37:39 +0100
>> Message-ID:
>> <caahxzx+epbb6+4fbhxvb7pk8nteox4fc+59hprtkgexmcad...@mail.gmail.com>
>>
>> Hi Daniel,
>>
>> Thanks a lot for your comments!
>>
>> Please check the new patch I attached, I hope it's good now.
>>
>> Thanks,
>> Janos
>>
>> On Sat, Jan 26, 2013 at 9:03 PM, Daniel Shahaf <[email protected]>
>> wrote:
>> > Please attach patches as MIME text/plain (usually naming them *.txt does
>> > that). More below.
>> >
>> >> + if prefix and re.search(r'REPONAME', prefix):
>> >
>> > Needlessly complicated, ('REPONAME' in prefix) would do.
>> >
>> > Also I think you should use the %() syntax like mailer.conf.example
>> > does. Is that possible?
>> >
>> >> + reponame =
>> >> os.path.basename(os.path.dirname(os.path.dirname(__file__)))
>> >
>> > That's outright wrong. You can't assume that post-commit is a symlink
>> > to mailer.py. (Just read post-commit.tmpl for a counterexample.)
>> >
>> >> + prefix = re.sub(r'REPONAME', reponame, prefix)
>> >
>> > Daniel
>> > (very brief review, and the setup I help maintain uses svnmailer not
>> > mailer.py, so if the above doesn't make sense sorry and please correct me)
>>
>>
>>
>> --
>> Janos Gyerik
>> http://www.janosgyerik.com/
>> https://twitter.com/janosgyerik/
>
>> Index: tools/hook-scripts/mailer/mailer.py
>> ===================================================================
>> --- tools/hook-scripts/mailer/mailer.py (revision 1438886)
>> +++ tools/hook-scripts/mailer/mailer.py (working copy)
>> @@ -98,7 +98,7 @@ def main(pool, cmd, config_fname, repos_dir, cmd_a
>> if cmd == 'commit':
>> revision = int(cmd_args[0])
>> repos = Repository(repos_dir, revision, pool)
>> - cfg = Config(config_fname, repos, { 'author' : repos.author })
>> + cfg = Config(config_fname, repos, { 'author' : repos.author, 'repodir'
>> : os.path.basename(repos.repos_dir) })
>> messenger = Commit(pool, cfg, repos)
>> elif cmd == 'propchange' or cmd == 'propchange2':
>> revision = int(cmd_args[0])
>
>
> ----- End forwarded message -----
--
Janos Gyerik
http://www.janosgyerik.com/
https://twitter.com/janosgyerik/
Index: tools/hook-scripts/mailer/mailer.py
===================================================================
--- tools/hook-scripts/mailer/mailer.py (revision 1438886)
+++ tools/hook-scripts/mailer/mailer.py (working copy)
@@ -98,7 +98,7 @@ def main(pool, cmd, config_fname, repos_dir, cmd_a
if cmd == 'commit':
revision = int(cmd_args[0])
repos = Repository(repos_dir, revision, pool)
- cfg = Config(config_fname, repos, { 'author' : repos.author })
+ cfg = Config(config_fname, repos, { 'author' : repos.author, 'repodir' :
os.path.basename(repos.repos_dir) })
messenger = Commit(pool, cfg, repos)
elif cmd == 'propchange' or cmd == 'propchange2':
revision = int(cmd_args[0])
@@ -108,14 +108,14 @@ def main(pool, cmd, config_fname, repos_dir, cmd_a
repos = Repository(repos_dir, revision, pool)
# Override the repos revision author with the author of the propchange
repos.author = author
- cfg = Config(config_fname, repos, { 'author' : author })
+ cfg = Config(config_fname, repos, { 'author' : author, 'repodir' :
os.path.basename(repos.repos_dir) })
messenger = PropChange(pool, cfg, repos, author, propname, action)
elif cmd == 'lock' or cmd == 'unlock':
author = cmd_args[0]
repos = Repository(repos_dir, 0, pool) ### any old revision will do
# Override the repos revision author with the author of the lock/unlock
repos.author = author
- cfg = Config(config_fname, repos, { 'author' : author })
+ cfg = Config(config_fname, repos, { 'author' : author, 'repodir' :
os.path.basename(repos.repos_dir) })
messenger = Lock(pool, cfg, repos, author, cmd == 'lock')
else:
raise UnknownSubcommand(cmd)
Index: tools/hook-scripts/mailer/mailer.conf.example
===================================================================
--- tools/hook-scripts/mailer/mailer.conf.example (revision 1438886)
+++ tools/hook-scripts/mailer/mailer.conf.example (working copy)
@@ -146,7 +146,16 @@
#
# from_addr = %(author)[email protected]
#
+# The substitution variable "repodir" is provided, and is set to
+# the directory name of the repository. This can be useful to set
+# a custom subject that can be re-used in multiple repositories:
#
+# commit_subject_prefix = [svn-%(repodir)s]
+#
+# For example if the repository is at /path/to/repo/project-x then
+# the subject of commit emails will be prefixed with [svn-project-x]
+#
+#
# SUMMARY
#
# While mailer.py will work to minimize the number of mail messages