Someone in #svn-dev IRC asked about the customizations to mailer.py running
on svn.collab.net for printing the Merged/Reverse-merged notifications.
Attached is the patch I used there. (And sorry for not sharing this earlier.)
--
C. Michael Pilato <cmpilato_at_collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Index: mailer.py
===================================================================
--- mailer.py (revision 254)
+++ mailer.py (revision 317)
@@ -676,6 +676,20 @@
else:
other_diffs = None
+ pathlist = map(lambda x: x[0], changelist)
+ commondir, pathlist = get_commondir(pathlist)
+ mergeinfo_old = mergeinfo_new = None
+ if commondir:
+ try:
+ mergeinfo_old = svn.fs.node_prop(repos.get_root(repos.rev - 1),
+ commondir,
+ svn.core.SVN_PROP_MERGEINFO)
+ mergeinfo_new = svn.fs.node_prop(repos.root_this,
+ commondir,
+ svn.core.SVN_PROP_MERGEINFO)
+ except:
+ pass
+
data = _data(
author=repos.author,
date=date,
@@ -694,6 +708,8 @@
diffs=DiffGenerator(changelist, paths, True, cfg, repos, date, group,
params, diffsels, diffurls, pool),
other_diffs=other_diffs,
+ mergeinfo_val=mergeinfo_new,
+ prev_mergeinfo_val=mergeinfo_old,
)
renderer.render(data)
@@ -1003,6 +1019,8 @@
else:
w('and changes in other areas\n')
+ self._render_mergeinfo_diff(data.prev_mergeinfo_val, data.mergeinfo_val)
+
self._render_diffs(data.diffs, '')
if data.other_diffs:
self._render_diffs(data.other_diffs,
@@ -1084,7 +1102,31 @@
for line in diff.content:
w(line.raw)
+ def _render_mergeinfo_diff(self, old_mergeinfo_val, new_mergeinfo_val):
+ """Pythonization of Subversion's diff.c:display_prop_diffs().
+ Output the differences between the mergeinfo stored in
+ ORIG_MERGEINFO_VAL and NEW_MERGEINFO_VAL in a human-readable form."""
+ w = self.output.write
+
+ old_mergeinfo = new_mergeinfo = None
+ if old_mergeinfo_val:
+ old_mergeinfo = svn.core.svn_mergeinfo_parse(old_mergeinfo_val)
+ if new_mergeinfo_val:
+ new_mergeinfo = svn.core.svn_mergeinfo_parse(new_mergeinfo_val)
+ deleted, added = svn.core.svn_mergeinfo_diff(old_mergeinfo,
+ new_mergeinfo, 1)
+ if deleted:
+ w('\nReverse-merged:\n')
+ for key, value in deleted.items():
+ revstr = svn.core.svn_rangelist_to_string(value)
+ w(' %s:r%s\n' % (key, svn.core.svn_rangelist_to_string(value)))
+ if added:
+ w('\nMerged:\n')
+ for key, value in added.items():
+ w(' %s:r%s\n' % (key, svn.core.svn_rangelist_to_string(value)))
+
+
class Repository:
"Hold roots and other information about the repository."
Received on 2008-11-04 19:11:27 CET