471,348 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

python svn pre-commit hook

This is a python script which is fired off from a batchfile pre-
commit.bat on Windows2000 server.

Everything I've read says that it should work & each part does work
when tested individually.

But when it runs within subversion this statement always ends with
this log_msg being an empty string.
log_msg = os.popen(log_cmd, 'r').readline().rstrip('\n')

Help. :-)
rem pre-commit.bat
c:\python23\python c:\repository\hooks\check-comments.py %1 %2

if errorlevel 1 goto :ERROR

exit 0

:ERROR

echo Error found in commit 1>&2

exit 1

#check-comments.py
import sys, os, string, re

SVNLOOK='c:\\subversion\\bin\\svnlook.exe'

# return true or false if this passed string is a valid comment
def check(comment):
#define regular expression
p = re.compile('\A[iI][sS][sS][uU][eE] \d+ - \w+')
return (p.match(comment) != None) #returns false if doesn't match

def result(r):
if r == 1:
sys.stderr.write ("Comments must have the format of 'Issue X -
Comment text' where X is the issue number.")
sys.exit(r)

def main(repos, txn):
log_cmd = '%s log -t "%s" "%s"' % (SVNLOOK, txn, repos)
log_msg = os.popen(log_cmd, 'r').readline().rstrip('\n')

if check(log_msg):
result(0)
else:
result(1)

if __name__ == '__main__':
if len(sys.argv) < 3:
sys.stderr.write("Usage: %s REPOS TXN\n" % (sys.argv[0]))
else:
main(sys.argv[1], sys.argv[2])

Jul 2 '07 #1
0 2889

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
1 post views Thread by M.E.Farmer | last post: by
113 posts views Thread by John Nagle | last post: by
16 posts views Thread by per9000 | last post: by
13 posts views Thread by =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= | last post: by
reply views Thread by eGenix Team: M.-A. Lemburg | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.