[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

mailer.py + for_paths

From: James Lamanna <james.lamanna_at_appliedminds.com>
Date: 2003-04-11 20:59:55 CEST

So I noticed that mailer.py doesn't seem to have the behavior I
expected.
It didn't honor any regexs in for_paths because it wasn't making any
associations between
groups and paths matching the regex. So essentially it was running the
diff for every group on every file.

Here is a patch that fixes that behavior, and also lets you specify a
diff program for each group,
using [groupname].diff

If I'm just totally missing something here, please tell me...

--James

Index: mailer.py
===================================================================
--- mailer.py (revision 5606)
+++ mailer.py (working copy)
@@ -60,8 +60,15 @@
     # turn the params into a hashable object and stash it away
     param_list = params.items()
     param_list.sort()
- groups[group, tuple(param_list)] = params

+ # collect the set of paths belonging to this group
+ if groups.has_key( (group, tuple(param_list)) ):
+ old_param, paths = groups[group, tuple(param_list)]
+ else:
+ paths = [ ]
+ paths.append(path)
+ groups[group, tuple(param_list)] = (params, paths)

   output = determine_output(cfg, repos, changelist)
   output.generate(groups, pool)
@@ -142,12 +147,12 @@

     subpool = svn.util.svn_pool_create(pool)

- for (group, param_tuple), params in groups.items():
+ for (group, param_tuple), (params, paths) in groups.items():
       self.start(group, params)

       # generate the content for this group and set of params
       generate_content(self, self.cfg, self.repos, self.changelist,
- group, params, subpool)
+ group, params, paths, subpool)

       self.finish()
       svn.util.svn_pool_clear(subpool)
@@ -220,7 +225,7 @@
     # use the default group and no parameters
     ### is that right?
     generate_content(self, self.cfg, self.repos, self.changelist,
- None, { }, pool)
+ None, { }, None, pool)

   def run_diff(self, cmd):
     # flush our output to keep the parent/child output in sync
@@ -312,8 +317,8 @@
     self.pipe.wait()

-def generate_content(output, cfg, repos, changelist, group, params,
pool):
-
+def generate_content(output, cfg, repos, changelist, group, params,
paths,
+ pool):
   svndate = repos.get_rev_prop(svn.util.SVN_PROP_REVISION_DATE)
   ### pick a different date format?
   date = time.ctime(svn.util.secs_from_timestr(svndate, pool))
@@ -331,6 +336,11 @@

   # these are sorted by path already
   for path, change in changelist:
+ if paths is not None:
+ try:
+ paths.index(path)
+ except ValueError:
+ continue
     generate_diff(output, cfg, repos, date, change, group, params,
pool)

@@ -443,7 +453,8 @@

   src_fname, dst_fname = diff.get_files()

- output.run_diff(cfg.get_diff_cmd({
+ output.run_diff(cfg.get_diff_cmd(group,
+ {
     'label_from' : label1,
     'label_to' : label2,
     'from' : src_fname,
@@ -664,9 +675,18 @@

     self._prep_groups(repos)

- def get_diff_cmd(self, args):
+ def get_diff_cmd(self, group, args):
     cmd = [ ]
- for part in self._diff_cmd:
+ diffcmd = ''
+ if group:
+ sub = getattr(self, group)
+ if hasattr(sub, 'diff'):
+ diffcmd = string.split(getattr(sub, 'diff'))
+ else:
+ diffcmd = self._diff_cmd
+ else:
+ diffcmd = self._diff_cmd
+ for part in diffcmd:
       cmd.append(part % args)
     return cmd

Index: mailer.conf.example
===================================================================
--- mailer.conf.example (revision 5606)
+++ mailer.conf.example (working copy)
@@ -164,6 +164,8 @@
 # to_addr = www-commits@example.com
 # # use the revision author as the from address
 # from_addr =
+# # add a custom diff program for this group
+# diff =
 #
 # [another-example]
 # # commits to personal repositories should go to that person

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Apr 11 21:50:29 2003

This is an archived mail posted to the Subversion Dev mailing list.