acl: improve undefined group error handling
authorPatrick Mezard <pmezard@gmail.com>
Mon, 10 May 2010 21:44:00 +0200
changeset 11140 1f26cf0a3663
parent 11139 f2c6b9819a6d
child 11141 df5d1d571d27
acl: improve undefined group error handling
hgext/acl.py
tests/test-acl
tests/test-acl.out
--- 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