On Wednesday 19 May 2004 09:34 am, John Peacock wrote:
> Robert M.Zigweid wrote:
> > Are there any plans to change this? It really would be nice to be able
> > to enforce a global policy. Is this something that could be done with
> > one of the pre-commit type hooks? Sometimes the big stick doesn't work
> > on people.
>
> Yes. Of course. Possibly. (in that order ;)
I'd refute the 'possibly'. You can place the big stick in your pre-commit
script:
Heres one I just hacked up:
pre-commit
#!/bin/sh
/usr/local/svn/test/hooks/checkprops $1 $2 >> /tmp/svnlog || exit 1
checkprops
#!/usr/bin/python
from ConfigParser import ConfigParser
from fnmatch import fnmatch
import sys,os
repos = sys.argv[1]
trans = sys.argv[2]
SVNLOOK = "/usr/bin/svnlook"
CONFIG = "%s/conf/config" % repos
MESSAGE = "set the auto-props in your subversion config file like the ones
here : http://blah/blah/config"
config = ConfigParser()
config.read(CONFIG)
autoprops = dict(config.items("auto-props"))
changes = os.popen("%s changed -t %s %s" % (SVNLOOK,trans,repos)).readlines()
def checkPath(path,autoprops):
okay = 1
for pattern in autoprops.keys():
if fnmatch(path,pattern):
items = map( lambda rule: rule.split("="),autoprops[pattern].split(";"))
for item in items:
propname = item[0]
expected = item[1]
propget = os.popen("%s propget -t %s %s %s %s" %
(SVNLOOK,trans,repos,propname,path))
propval = propget.read()
status = propget.close()
if propval.find(expected) < 0:
okay = 0
if not status:
sys.stderr.write("hook: Property value '%s:%s' not found on path
'%s'\n" % (propname,expected,path))
return okay
failures = 0
for change in changes:
if change[0] == 'A':
path = change[4:].strip()
if not checkPath(path,autoprops):
sys.stderr.write("props not set correctly for %s\n" % path)
failures = 1
if failures:
hr = "\n" + "-" * 80 + "\n"
sys.stderr.write(hr + MESSAGE + hr)
sys.exit(failures)
Go ahead and bash my python, but it _is_ possible to enforce these rules.
Regards,
Ian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed May 19 18:44:40 2004