[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] Re: CVSROOT/loginfo
From:       Rob Kaper <cap () capsi ! com>
Date:       2001-07-28 22:05:12
[Download RAW message or body]

On Sat, Jul 28, 2001 at 11:46:00PM +0200, Rob Kaper wrote:
> I'd like to change CVSROOT/loginfo to add a syncmail line for
> kdenonbeta/kmonop so that CVS commits go to the kmonop-devel mailinglist.
> 
> This would however stop those commits from going to kde-cvs. Would that be
> a problem? If so, anyone with sufficient CVS knowledge to add a target for
> loginfo while keeping the default action for that target as well?

Thank you, Google.

Attached patch should do just this, as well as upgrading syncmail to a more
recent version.

Please review (and in case there are ACL's on CVSROOT which I suppose there
are, please commit).

Rob
-- 
Rob Kaper     | 'I hate it when the villain quotes Shakespeare'
cap@capsi.com |         -- John Crichton, "Farscape"
www.capsi.com |

["cvsroot.diff" (text/plain)]

Index: checkoutlist
===================================================================
RCS file: /home/kde/CVSROOT/checkoutlist,v
retrieving revision 1.4
diff -u -3 -d -p -r1.4 checkoutlist
--- checkoutlist	2001/05/25 19:38:17	1.4
+++ checkoutlist	2001/07/28 21:59:05
@@ -15,3 +15,5 @@
 cvs_acls.pl
 # loginfo.pl - used to send a log message to the kde-cvs@kde.org list
 loginfo.pl
+# syncmail - used to send a log message to kmonop-devel@lists.capsi.com
+syncmail
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/07/28 21:59:05
@@ -16,5 +16,5 @@
 # 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/kmonop $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/07/28 21:59:05
@@ -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