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

[PATCH] Teach mailer.py to show top-level mergeinfo diffs.

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: Wed, 12 Mar 2008 16:58:05 -0400

Make mailer.py provide mergeinfo change information for the longest
common directory of the paths modified.

        # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        # #
        # This has not been reviewed with an eye on general #
        # inclusion in Subversion's mailer.py. It's just #
        # what I plopped on svn.collab.net. Just sharing #
        # in case someone else wants to run with this. #
        # #
        # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

* tools/hook-scripts/mailer/mailer.py
   (generate_content): Fetch the old and new mergeinfo property values
     for the longest-common-directory of the changed paths, and pass
     the results via the data dictionary.
   (TextCommitRenderer.render): Call self._render_mergeinfo_diff().
   (TextCommitRenderer._render_mergeinfo_diff): Use the new data
     dictionary members to generate a textual description of mergeinfo
     changes.

-- 
C. Michael Pilato <cmpilato_at_collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Index: tools/hook-scripts/mailer/mailer.py
===================================================================
--- tools/hook-scripts/mailer/mailer.py (revision 29877)
+++ tools/hook-scripts/mailer/mailer.py (working copy)
@@ -676,6 +676,17 @@
   else:
     other_diffs = None
 
+ pathlist = map(lambda x: x[0], changelist)
+ commondir, pathlist = get_commondir(pathlist)
+ mergeinfo_old = mergeinfo_new = None
+ if commondir:
+ 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)
+
   data = _data(
     author=repos.author,
     date=date,
@@ -694,6 +705,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 +1016,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 +1099,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-03-12 21:58:19 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.