Mercurial > hg
changeset 11140:1f26cf0a3663
acl: improve undefined group error handling
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 10 May 2010 21:44:00 +0200 |
parents | f2c6b9819a6d |
children | df5d1d571d27 |
files | hgext/acl.py tests/test-acl tests/test-acl.out |
diffstat | 3 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/acl.py Mon May 10 21:15:12 2010 +0200 +++ b/hgext/acl.py Mon May 10 21:44:00 2010 +0200 @@ -161,7 +161,10 @@ ui.debug('acl: "%s" not defined in [acl.groups]\n' % group) # If no users found in group definition, get users from OS-level group - return util.groupmembers(group) + try: + return util.groupmembers(group) + except KeyError: + raise util.Abort(_("group '%s' is undefined") % group) def _usermatch(ui, user, usersorgroups):
--- a/tests/test-acl Mon May 10 21:15:12 2010 +0200 +++ b/tests/test-acl Mon May 10 21:44:00 2010 +0200 @@ -165,4 +165,12 @@ echo "@group is allowed inside anything but foo/Bar/" do_push fred +echo 'Invalid group' +# Disable the fakegroups trick to get real failures +grep -v fakegroups $config > config.tmp +mv config.tmp $config +echo '[acl.allow]' >> $config +echo "** = @unlikelytoexist" >> $config +do_push fred 2>&1 | grep unlikelytoexist +true
--- a/tests/test-acl.out Mon May 10 21:15:12 2010 +0200 +++ b/tests/test-acl.out Mon May 10 21:44:00 2010 +0200 @@ -1557,3 +1557,8 @@ no rollback information available 0:6675d58eff77 +Invalid group +** = @unlikelytoexist +acl: "unlikelytoexist" not defined in [acl.groups] +error: pretxnchangegroup.acl hook failed: group 'unlikelytoexist' is undefined +abort: group 'unlikelytoexist' is undefined