Hi,
The svnperms.py script reads the svnperms.conf file, which needs the
section rules for all the repos uniquely. This was quite tough when we
have n number if repos. I wished that svnperms.py reads regex matches
and applies the configuration rules and came up with this patch.
Mid-way of my coding work, I came to know that -s switch would let us
specify the section name explicitly, but not the regex thing.
I modified the code to search for a matching section via regex, which
might be really helpfull for certain cases.
I have attached the log file and the patch file with this mail for
review.
Thanks and regards,
Prabhu
<[email protected]>
Index: tools/hook-scripts/svnperms.py
===================================================================
--- tools/hook-scripts/svnperms.py (revision 999888)
+++ tools/hook-scripts/svnperms.py (working copy)
@@ -227,6 +227,7 @@
def check_perms(filename, section, repos, txn=None, rev=None, author=None):
svnlook = SVNLook(repos, txn=txn, rev=rev)
+ found_repo_block = 0
if author is None:
author = svnlook.author()
changes = svnlook.changed()
@@ -234,8 +235,19 @@
config = Config(filename)
except IOError:
raise Error("can't read config file "+filename)
+
if not section in config.sections():
- raise Error("section '%s' not found in config file" % section)
+ # loop until there is a group/repo entry in the svnperms.conf file
+ for rsection in config.sections():
+ matchobj = re.match(rsection, section, re.I)
+ if matchobj:
+ section = rsection
+ found_repo_block = 1
+ break
+ if found_repo_block == 0:
+ raise Error("section '%s' not found in config file" \
+ % section)
+
perm = Permission()
perm.parse_groups(config.walk("groups"))
perm.parse_groups(config.walk(section+" groups"))
Index: tools/hook-scripts/svnperms.conf.example
===================================================================
--- tools/hook-scripts/svnperms.conf.example (revision 999888)
+++ tools/hook-scripts/svnperms.conf.example (working copy)
@@ -94,3 +94,9 @@
[example5 extends example2]
releases/[^/]+/ = *(add)
+#Regex based repo blocks. Order of blocks should be most relevant
+#to least relevant(So Author .* after all repo specific regexes.)
+[.*]
+trunk/.* = user8(add,update)
+tags/[^/]+/ = @group1(add)
+branches/[^/]+/.* = *(add,remove,update)
[[[
Make svnperms.py to accept repo section names via regex rather than absolute.
* tools/hook-scripts/svnperms.py
(check_perms): If absolute section is not found, try to find it by
matching as a regex.
* tools/hook-scripts/svnperms.conf.example
(): Add some default section example.
Patch by: Prabhu Gnana Sundar <[email protected]>
]]]