[Mailman-Developers] I patched syncmail to look prettier to my eyes.

zooko@mad-scientist.com zooko@mad-scientist.com
Thu, 28 Sep 2000 12:05:21 -0700


Greetings, Mailman Cabalists!


I followed the instructions[1] on SourceForge to get mail sent to my
development list about CVS commits.  Someone requested unified diffs
instead of context diffs, and I agreed, so I made the following patch to
syncmail, which passes the "-u" and "--minimal" flags to CVS diff, and
which strips out unnecessary (to me) header lines from the cvs diff
output.


The project of which I speak, by the way, is Mojo Nation[2], an open
source, highly distributed file sharing system with integrated
micropayments, written in Python.


Regards,

Zooko

(patch appended)

[1] http://sfdocs.sourceforge.net/sfdocs/display_topic.php?topicid=52
[2] http://mojonation.net/

--- syncmail    2000/09/07 03:26:44     3.12
+++ syncmail    2000/09/20 20:09:35     3.19
@@ -3,6 +3,8 @@
 
 """Complicated notification for CVS checkins.
 
+Hello!  Zooko touched this.
+
 This script is used to provide email notifications of changes to the CVS
 repository.  These email changes will include context diffs of the changes.
 Really big diffs will be trimmed.
@@ -94,7 +96,8 @@
     else:
         # This /has/ to happen in the background, otherwise we'll run into CVS
         # lock contention.  What a crock.
-        diffcmd = '/usr/bin/cvs -f diff -kk -C 2 -r %s -r %s %s' % (
+        # Zooko added "--minimal -u" here.  --Zooko 2000-09-20
+        diffcmd = 'cvs -f diff -kk --minimal -u -r %s -r %s %s' % (
             oldrev, newrev, file)
         fp = os.popen(diffcmd)
         lines = fp.readlines()
@@ -102,6 +105,11 @@
         # ignore the error code, it always seems to be 1 :(
 ##        if sts:
 ##            return 'Error code %d occurred during diff\n' % (sts >> 8)
+
+    # Zooko's hack to get rid of unnecessary header lines:
+    # (This hopefully includes only "diff" statements and unified diff text.)
+    lines = filter(lambda l: (not l) or (l[0] in "+-@d "), lines)
+
     if len(lines) > DIFF_TRUNCATE_IF_LARGER:
         removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
         del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]