I patched syncmail to look prettier to my eyes.
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]
On Thu, Sep 28, 2000 at 12:05:21PM -0700, zooko@mad-scientist.com wrote:
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.
Uhm, I'm right in assuming this changes it for *all* checkin messages, and not based on who gets the message, right ? I hope Barry doesn't apply it then ;) I used to prefer unified over context, but the python-checkins list has made me seen the light. Context diffs make it much easier to see both the old and the new code. This is highly personal, of course ;P Isn't there a tool that translates context diffs to unified diffs and vice-versa (if Barry does apply this patch, I will need it myself ;)
-- Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
"TW" == Thomas Wouters <thomas@xs4all.net> writes:
>> 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.
Fred was just musing that the syncmail script, is both a historical misnomer, and seems to be used in a lot of projects now. He wondered whether we should rename it and make it more available to the SourceForge community at large. I'd be all for that, and am willing to add it as a Python snippet on SF.
TW> Uhm, I'm right in assuming this changes it for *all* checkin
TW> messages, and not based on who gets the message, right ?
Can't do that, unless you have two recipient lists. I never thought the diff style was worth going to all that extra trouble.
TW> I hope Barry doesn't apply it then ;) I used to prefer unified
TW> over context, but the python-checkins list has made me seen
TW> the light. Context diffs make it much easier to see both the
TW> old and the new code. This is highly personal, of course ;P
Thomas will laugh at me now, but I've been trying to teach/force myself to use unified diffs in my private environment. I think I'm getting the hang of them, but I /still/ find context diffs easier to read.
TW> Isn't there a tool that translates context diffs to unified
TW> diffs and vice-versa (if Barry does apply this patch, I will
TW> need it myself ;)
Never heard of one. I think context diffs still make the most sense for syncmail.
-Barry
Barry A. Warsaw writes:
Fred was just musing that the syncmail script, is both a historical misnomer, and seems to be used in a lot of projects now. He wondered whether we should rename it and make it more available to the SourceForge community at large. I'd be all for that, and am willing to add it as a Python snippet on SF.
Snippets don't have documentation; syncmail does:
https://sourceforge.net/docman/display_doc.php?docid=772&group_id=1
A separate project is too much, though, so I'm not sure what to do.
Can't do that, unless you have two recipient lists. I never thought the diff style was worth going to all that extra trouble.
It probably is worth supporting per-use configuration, though; support -c/-u to specify which to use seems reasonable, and --minimal would be nice as well (implemented appropriately for both context & unified diffs).
Never heard of one. I think context diffs still make the most sense for syncmail.
So they should be the default.
-Fred
-- Fred L. Drake, Jr. <fdrake at beopen.com> BeOpen PythonLabs Team Member
participants (4)
-
bwarsaw@beopen.com
-
Fred L. Drake, Jr.
-
Thomas Wouters
-
zooko@mad-scientist.com