Whenever I see a prop-change email (usually for svn:log) I always wonder what has been changed, and so I would like it to show the previous value or preferably a diff.
I have implemented this by having the pre- and post-revprop-change hook scripts save a copy of the property value, and then propchange-email.pl do a diff of the two saved copies. Theoretically this could be confused by simultaneous changes, but in practice for most of us this is very unlikely.
The way I have written the hook scripts only works for the "svn:log" property, and only on Unix-like systems.
A patch is attached but it is only for further development, not for committing. Note that it includes patches to "pre-" and "post-revprop-change.tmpl", rather than to the source code that writes these files.
It would be neater if, instead, propchange-email.pl were called in a "pre-change" mode to save the previous value, and then called in the normal (post-change) mode to compare its saved value with the new value and do the rest of its work. My Perl skills are not up to the task, so I am sort of hoping that someone else might like to do that.
- Julian
Put diffs in property change emails, not just the new value of the property.
### I don't consider this patch to be finished yet.
* tools/hook-scripts/propchange-email.pl.in
Use GNU diff to compare previously saved old and new log messages.
Fix a comment.
* pre-revprop-change.tmpl
* post-revprop-change.tmpl
Save a copy of the property value for use by propchange-email.pl.
Index: tools/hook-scripts/propchange-email.pl.in
===================================================================
--- tools/hook-scripts/propchange-email.pl.in (revision 9091)
+++ tools/hook-scripts/propchange-email.pl.in (working copy)
@@ -36,6 +36,9 @@
######################################################################
# Configuration section.
+# GNU diff path.
+my $gnudiff = "/usr/bin/diff";
+
# Sendmail path.
my $sendmail = "/usr/sbin/sendmail";
@@ -50,7 +53,7 @@
# the administrator has set up the script properly.
{
my $ok = 1;
- foreach my $program ($sendmail, $svnlook, $svn)
+ foreach my $program ($gnudiff, $sendmail, $svnlook, $svn)
{
if (-e $program)
{
@@ -80,8 +83,8 @@
my @project_settings_list = (&new_project);
# Process the command line arguments till there are none left. The
-# first three arguments that are not used by a command line option are
-# the repository path, the revision number, and the property name.
+# first four arguments that are not used by a command line option are
+# the repository path, the revision number, the author, and the property name.
my $repos;
my $rev;
my $author;
@@ -210,12 +213,18 @@
}
######################################################################
-# Harvest data using svn.
+# Harvest data.
-# Get the new property value svn.
-my $repos_url = 'file://' . &abs_path($repos);
-my @svnlines = &read_from_process($svn, 'propget', '--revprop', '-r', $rev,
- $propname, $repos_url);
+## Get the new property value using svn.
+#my $repos_url = 'file://' . &abs_path($repos);
+#my @svnlines = &read_from_process($svn, 'propget', '--revprop', '-r', $rev,
+# $propname, $repos_url);
+
+# Get the diff.
+my $propfile = 'r' . $rev . '-' . $propname;
+my ($status, @difflines) = &safe_read_from_pipe($gnudiff,
+ '-u', '-L', 'old', '-L', 'new',
+ $propfile . '.old', $propfile . '.new');
# Figure out what directories have changed using svnlook. This is
# merely so we can determine what project might care about receiving
@@ -232,9 +241,7 @@
push(@body, "Revision: $rev\n");
push(@body, "Property Name: $propname\n");
push(@body, "\n");
-push(@body, "New Property Value:\n");
-push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @svnlines);
-push(@body, "\n");
+push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines);
# Go through each project and see if there are any matches for this
# project. If so, send the log out.
Index: pre-revprop-change.tmpl
===================================================================
--- pre-revprop-change.tmpl 2003-11-17 23:07:03.000000000 +0000
+++ pre-revprop-change.tmpl 2004-03-17 00:44:45.000000000 +0000
@@ -45,5 +45,10 @@
USER="$3"
PROPNAME="$4"
-if [ "$PROPNAME" = "svn:log" ]; then exit 0; fi
+if [ "$PROPNAME" = "svn:log" ]; then
+ NAME="r$REV-$PROPNAME"
+ svnlook log -r $REV $REPOS > $NAME.old
+ exit 0
+fi
+
exit 1
Index: post-revprop-change.tmpl
===================================================================
--- post-revprop-change.tmpl 2003-11-17 23:07:03.000000000 +0000
+++ post-revprop-change.tmpl 2004-03-17 15:59:02.000000000 +0000
@@ -37,4 +37,9 @@
USER="$3"
PROPNAME="$4"
+if [ "$PROPNAME" = "svn:log" ]; then
+ NAME="r$REV-$PROPNAME"
+ svnlook log -r $REV $REPOS > $NAME.new
+fi
+
propchange-email.pl "$REPOS" "$REV" "$USER" "$PROPNAME" watchers@example.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 17 17:05:10 2004