# HG changeset patch # User Patrick Mezard # Date 1273520640 -7200 # Node ID 1f26cf0a36635fe9f87b289c752127f71f2d1119 # Parent f2c6b9819a6d41582b3e69c991fab766f14f2728 acl: improve undefined group error handling diff -r f2c6b9819a6d -r 1f26cf0a3663 hgext/acl.py --- 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): diff -r f2c6b9819a6d -r 1f26cf0a3663 tests/test-acl --- 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 diff -r f2c6b9819a6d -r 1f26cf0a3663 tests/test-acl.out --- 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