[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] CVSROOT/loginfo
From: Rob Kaper <cap () capsi ! com>
Date: 2001-11-05 0:45:35
[Download RAW message or body]
Can someone with enough karma please commit this patch for CVSROOT?
It allows Atlantik commits to go to the kmonop-devel mailinglist and not
just kde-cvs. It also upgrades the syncmail script to allow unified diffs to
be sent in the message body.
Thanks,
Rob
--
Rob Kaper | "They that can give up essential liberty to obtain a little
cap@capsi.com | temporary safety deserve neither liberty nor safety."
www.capsi.com | - Benjamin Franklin, Historical Review of Pennsylvania, 1759
["loginfo.diff" (text/plain)]
Index: loginfo
===================================================================
RCS file: /home/kde/CVSROOT/loginfo,v
retrieving revision 1.22
diff -u -3 -d -p -r1.22 loginfo
--- loginfo 2000/08/31 14:56:50 1.22
+++ loginfo 2001/11/05 00:39:16
@@ -16,5 +16,6 @@
# name and listing the modified file names.
#
# For example:
-DEFAULT (echo ""; echo %{sVv}; echo "Author: $USER"; date; cat) | $CVSROOT/CVSROOT/loginfo.pl
+ALL (echo ""; echo %{sVv}; echo "Author: $USER"; date; cat) | $CVSROOT/CVSROOT/loginfo.pl
+^kdenonbeta/atlantik $CVSROOT/CVSROOT/syncmail -u %{sVv} kmonop-devel@lists.capsi.com
Index: syncmail
===================================================================
RCS file: /home/kde/CVSROOT/syncmail,v
retrieving revision 1.1
diff -u -3 -d -p -r1.1 syncmail
--- syncmail 2000/12/19 02:31:46 1.1
+++ syncmail 2001/11/05 00:39:17
@@ -39,6 +39,16 @@ Where options is:
-h
Print this text.
+ --context=#
+ -C #
+ Include # lines of context around lines that differ (default: 2).
+
+ -c
+ Produce a context diff (default).
+
+ -u
+ Produce a unified diff (smaller, but harder to read).
+
<%%S>
CVS %%s loginfo expansion. When invoked by CVS, this will be a single
string containing the directory the checkin is being made in, relative
@@ -77,7 +87,7 @@ def usage(code, msg=''):
-def calculate_diff(filespec):
+def calculate_diff(filespec, contextlines):
try:
file, oldrev, newrev = string.split(filespec, ',')
except ValueError:
@@ -92,7 +102,7 @@ def calculate_diff(filespec):
fp = os.popen(update_cmd)
lines = fp.readlines()
fp.close()
- lines.insert(0, '--- NEW FILE ---\n')
+ lines.insert(0, '--- NEW FILE: %s ---\n' % file)
except IOError, e:
lines = ['***** Error reading new file: ',
str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()]
@@ -101,8 +111,12 @@ def calculate_diff(filespec):
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' % (
- oldrev, newrev, file)
+ if contextlines > 0:
+ difftype = "-C " + str(contextlines)
+ else:
+ difftype = "-u"
+ diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s '%s'" % (
+ difftype, oldrev, newrev, file)
fp = os.popen(diffcmd)
lines = fp.readlines()
sts = fp.close()
@@ -118,7 +132,7 @@ def calculate_diff(filespec):
-def blast_mail(mailcmd, filestodiff):
+def blast_mail(mailcmd, filestodiff, contextlines):
# cannot wait for child process or that will cause parent to retain cvs
# lock for too long. Urg!
if not os.fork():
@@ -130,7 +144,7 @@ def blast_mail(mailcmd, filestodiff):
fp.write('\n')
# append the diffs if available
for file in filestodiff:
- fp.write(calculate_diff(file))
+ fp.write(calculate_diff(file, contextlines))
fp.write('\n')
fp.close()
# doesn't matter what code we return, it isn't waited on
@@ -140,8 +154,10 @@ def blast_mail(mailcmd, filestodiff):
# scan args for options
def main():
+ contextlines = 2
try:
- opts, args = getopt.getopt(sys.argv[1:], 'h', ['cvsroot=', 'help'])
+ opts, args = getopt.getopt(sys.argv[1:], 'hC:cu',
+ ['context=', 'cvsroot=', 'help'])
except getopt.error, msg:
usage(1, msg)
@@ -151,6 +167,13 @@ def main():
usage(0)
elif opt == '--cvsroot':
os.environ['CVSROOT'] = arg
+ elif opt in ('-C', '--context'):
+ contextlines = int(arg)
+ elif opt == '-c':
+ if contextlines <= 0:
+ contextlines = 2
+ elif opt == '-u':
+ contextlines = 0
# What follows is the specification containing the files that were
# modified. The argument actually must be split, with the first component
@@ -175,8 +198,17 @@ def main():
return
if specs[-3:] == ['-', 'New', 'directory']:
del specs[-3:]
+ elif len(specs) > 2:
+ L = specs[:2]
+ for s in specs[2:]:
+ prev = L[-1]
+ if string.count(prev, ",") < 2:
+ L[-1] = "%s %s" % (prev, s)
+ else:
+ L.append(s)
+ specs = L
print 'Generating notification message...'
- blast_mail(mailcmd, specs[1:])
+ blast_mail(mailcmd, specs[1:], contextlines)
print 'Generating notification message... done.'
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic