Mercurial > hg-stable
changeset 15207:0f7f9f06c759
acl: more descriptive error messages
author | Elifarley Callado Coelho Cruz |
---|---|
date | Thu, 06 Oct 2011 19:45:26 -0300 |
parents | f85c76b16f27 |
children | d0694223861a |
files | hgext/acl.py tests/test-acl.t |
diffstat | 2 files changed, 91 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/acl.py Thu Oct 06 11:10:06 2011 +0200 +++ b/hgext/acl.py Thu Oct 06 19:45:26 2011 -0300 @@ -216,6 +216,8 @@ if user is None: user = getpass.getuser() + ui.debug('acl: checking access for user "%s"\n' % user) + cfg = ui.config('acl', 'config') if cfg: ui.readconfig(cfg, sections = ['acl.groups', 'acl.allow.branches', @@ -242,9 +244,9 @@ for f in ctx.files(): if deny and deny(f): - ui.debug('acl: user %s denied on %s\n' % (user, f)) - raise util.Abort(_('acl: access denied for changeset %s') % ctx) + raise util.Abort(_('acl: user "%s" denied on "%s"' + ' (changeset "%s")') % (user, f, ctx)) if allow and not allow(f): - ui.debug('acl: user %s not allowed on %s\n' % (user, f)) - raise util.Abort(_('acl: access denied for changeset %s') % ctx) - ui.debug('acl: allowing changeset %s\n' % ctx) + raise util.Abort(_('acl: user "%s" not allowed on "%s"' + ' (changeset "%s")') % (user, f, ctx)) + ui.debug('acl: path access granted: "%s"\n' % ctx)
--- a/tests/test-acl.t Thu Oct 06 11:10:06 2011 +0200 +++ b/tests/test-acl.t Thu Oct 06 19:45:26 2011 -0300 @@ -232,16 +232,17 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow not enabled acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 0 (undo push) @@ -299,16 +300,16 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 0 entries for user fred acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: user fred not allowed on foo/file.txt - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374 + error: pretxnchangegroup.acl hook failed: acl: user "fred" not allowed on "foo/file.txt" (changeset "ef1ea85a6374") transaction abort! rollback completed - abort: acl: access denied for changeset ef1ea85a6374 + abort: acl: user "fred" not allowed on "foo/file.txt" (changeset "ef1ea85a6374") no rollback information available 0:6675d58eff77 @@ -364,20 +365,20 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user fred acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: user fred not allowed on quux/file.py - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae + error: pretxnchangegroup.acl hook failed: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae") transaction abort! rollback completed - abort: acl: access denied for changeset 911600dab2ae + abort: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae") no rollback information available 0:6675d58eff77 @@ -434,16 +435,16 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "barney" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 0 entries for user barney acl: acl.deny enabled, 0 entries for user barney acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: user barney not allowed on foo/file.txt - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374 + error: pretxnchangegroup.acl hook failed: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374") transaction abort! rollback completed - abort: acl: access denied for changeset ef1ea85a6374 + abort: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374") no rollback information available 0:6675d58eff77 @@ -501,20 +502,20 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user fred acl: acl.deny enabled, 1 entries for user fred acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: user fred not allowed on quux/file.py - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae + error: pretxnchangegroup.acl hook failed: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae") transaction abort! rollback completed - abort: acl: access denied for changeset 911600dab2ae + abort: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae") no rollback information available 0:6675d58eff77 @@ -573,18 +574,18 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user fred acl: acl.deny enabled, 2 entries for user fred acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: user fred denied on foo/Bar/file.txt - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset f9cafe1212c8 + error: pretxnchangegroup.acl hook failed: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8") transaction abort! rollback completed - abort: acl: access denied for changeset f9cafe1212c8 + abort: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8") no rollback information available 0:6675d58eff77 @@ -642,16 +643,16 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "barney" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 0 entries for user barney acl: acl.deny enabled, 0 entries for user barney acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: user barney not allowed on foo/file.txt - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374 + error: pretxnchangegroup.acl hook failed: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374") transaction abort! rollback completed - abort: acl: access denied for changeset ef1ea85a6374 + abort: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374") no rollback information available 0:6675d58eff77 @@ -713,16 +714,17 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "barney" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user barney acl: acl.deny enabled, 0 entries for user barney acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 0 (undo push) @@ -787,20 +789,20 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "wilma" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user wilma acl: acl.deny enabled, 0 entries for user wilma acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: user wilma not allowed on quux/file.py - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae + error: pretxnchangegroup.acl hook failed: acl: user "wilma" not allowed on "quux/file.py" (changeset "911600dab2ae") transaction abort! rollback completed - abort: acl: access denied for changeset 911600dab2ae + abort: acl: user "wilma" not allowed on "quux/file.py" (changeset "911600dab2ae") no rollback information available 0:6675d58eff77 @@ -865,6 +867,7 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "barney" error: pretxnchangegroup.acl hook raised an exception: [Errno 2] No such file or directory: '../acl.config' transaction abort! rollback completed @@ -937,20 +940,20 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "betty" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user betty acl: acl.deny enabled, 0 entries for user betty acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: user betty not allowed on quux/file.py - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae + error: pretxnchangegroup.acl hook failed: acl: user "betty" not allowed on "quux/file.py" (changeset "911600dab2ae") transaction abort! rollback completed - abort: acl: access denied for changeset 911600dab2ae + abort: acl: user "betty" not allowed on "quux/file.py" (changeset "911600dab2ae") no rollback information available 0:6675d58eff77 @@ -1021,16 +1024,17 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "barney" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user barney acl: acl.deny enabled, 0 entries for user barney acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 0 (undo push) @@ -1096,16 +1100,17 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user fred acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 0 (undo push) @@ -1167,18 +1172,18 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow enabled, 1 entries for user fred acl: acl.deny enabled, 1 entries for user fred acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: user fred denied on foo/Bar/file.txt - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset f9cafe1212c8 + error: pretxnchangegroup.acl hook failed: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8") transaction abort! rollback completed - abort: acl: access denied for changeset f9cafe1212c8 + abort: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8") no rollback information available 0:6675d58eff77 @@ -1241,17 +1246,18 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: "group1" not defined in [acl.groups] acl: acl.allow enabled, 1 entries for user fred acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 0 (undo push) @@ -1313,6 +1319,7 @@ files: 3/3 chunks (100.00%) added 3 changesets with 3 changes to 3 files calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "fred" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: "group1" not defined in [acl.groups] @@ -1320,13 +1327,12 @@ acl: "group1" not defined in [acl.groups] acl: acl.deny enabled, 1 entries for user fred acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: user fred denied on foo/Bar/file.txt - error: pretxnchangegroup.acl hook failed: acl: access denied for changeset f9cafe1212c8 + error: pretxnchangegroup.acl hook failed: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8") transaction abort! rollback completed - abort: acl: access denied for changeset f9cafe1212c8 + abort: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8") no rollback information available 0:6675d58eff77 @@ -1434,18 +1440,19 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "astro" acl: acl.allow.branches not enabled acl: acl.deny.branches not enabled acl: acl.allow not enabled acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" - acl: allowing changeset e8fc755d4d82 + acl: path access granted: "e8fc755d4d82" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 2 (undo push) @@ -1513,16 +1520,17 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "astro" acl: acl.allow.branches not enabled acl: acl.deny.branches enabled, 1 entries for user astro acl: acl.allow not enabled acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" error: pretxnchangegroup.acl hook failed: acl: user "astro" denied on branch "foobar" (changeset "e8fc755d4d82") transaction abort! rollback completed @@ -1590,6 +1598,7 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "astro" acl: acl.allow.branches enabled, 0 entries for user astro acl: acl.deny.branches not enabled acl: acl.allow not enabled @@ -1663,6 +1672,7 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "astro" acl: acl.allow.branches enabled, 0 entries for user astro acl: acl.deny.branches not enabled acl: acl.allow not enabled @@ -1730,18 +1740,19 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "george" acl: acl.allow.branches enabled, 1 entries for user george acl: acl.deny.branches not enabled acl: acl.allow not enabled acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" - acl: allowing changeset e8fc755d4d82 + acl: path access granted: "e8fc755d4d82" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 2 (undo push) @@ -1814,18 +1825,19 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "george" acl: acl.allow.branches enabled, 1 entries for user george acl: acl.deny.branches not enabled acl: acl.allow not enabled acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" - acl: allowing changeset ef1ea85a6374 + acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" - acl: allowing changeset f9cafe1212c8 + acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" - acl: allowing changeset 911600dab2ae + acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" - acl: allowing changeset e8fc755d4d82 + acl: path access granted: "e8fc755d4d82" updating the branch cache checking for updated bookmarks repository tip rolled back to revision 2 (undo push) @@ -1897,6 +1909,7 @@ files: 4/4 chunks (100.00%) added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook + acl: checking access for user "george" acl: acl.allow.branches not enabled acl: acl.deny.branches enabled, 1 entries for user george acl: acl.allow not enabled