"syncmail" in CVS repository
Juergen Hermann
jhe at webde-ag.de
Tue Jun 6 11:57:11 EDT 2000
Hi!
I made the following change to the syncmail script (fixes an
ugly error msg when committing a file for the first time).
--- syncmail 2000/05/20 17:50:34 1.2
+++ syncmail 2000/06/06 14:54:40
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/env python
"""Complicated notification for CVS checkins.
@@ -79,16 +79,26 @@
except ValueError:
# No diff to report
return ''
- # This /has/ to happen in the background, otherwise we'll run into CVS
- # lock contention. What a crock.
- diffcmd = '/usr/bin/cvs -f diff -C 2 -r %s -r %s %s' % (
- oldrev, newrev, file)
- fp = os.popen(diffcmd)
- lines = fp.readlines()
- sts = fp.close()
- # ignore the error code, it always seems to be 1 :(
-## if sts:
-## return 'Error code %d occurred during diff\n' % (sts >> 8)
+
+ if oldrev == "NONE":
+ try:
+ lines = open(file, "rt").readlines()
+ lines.insert(0, "--- NEW FILE ---\n")
+ except:
+ # Something's gone wrong, give up
+ return ''
+ 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 -u -r %s -r %s %s' % (
+ oldrev, newrev, file)
+ fp = os.popen(diffcmd)
+ lines = fp.readlines()
+ sts = fp.close()
+ # ignore the error code, it always seems to be 1 :(
+ ## if sts:
+ ## return 'Error code %d occurred during diff\n' % (sts >> 8)
+
if len(lines) > DIFF_TRUNCATE_IF_LARGER:
removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]
Ciao, Jürgen
--
Jürgen Hermann (jhe at webde-ag.de)
WEB.DE AG, Amalienbadstr.41, D-76227 Karlsruhe
Tel.: 0721/94329-0, Fax: 0721/94329-22
More information about the Python-list
mailing list