305 # Path-based ACL |
306 # Path-based ACL |
306 if pats: |
307 if pats: |
307 return match.match(repo.root, '', pats) |
308 return match.match(repo.root, '', pats) |
308 return util.never |
309 return util.never |
309 |
310 |
|
311 def ensureenabled(ui): |
|
312 """make sure the extension is enabled when used as hook |
|
313 |
|
314 When acl is used through hooks, the extension is never formally loaded and |
|
315 enabled. This has some side effect, for example the config declaration is |
|
316 never loaded. This function ensure the extension is enabled when running |
|
317 hooks. |
|
318 """ |
|
319 if 'acl' in ui._knownconfig: |
|
320 return |
|
321 ui.setconfig('extensions', 'acl', '', source='internal') |
|
322 extensions.loadall(ui, ['acl']) |
|
323 |
310 def hook(ui, repo, hooktype, node=None, source=None, **kwargs): |
324 def hook(ui, repo, hooktype, node=None, source=None, **kwargs): |
|
325 |
|
326 ensureenabled(ui) |
|
327 |
311 if hooktype not in ['pretxnchangegroup', 'pretxncommit']: |
328 if hooktype not in ['pretxnchangegroup', 'pretxncommit']: |
312 raise error.Abort(_('config error - hook type "%s" cannot stop ' |
329 raise error.Abort(_('config error - hook type "%s" cannot stop ' |
313 'incoming changesets nor commits') % hooktype) |
330 'incoming changesets nor commits') % hooktype) |
314 if (hooktype == 'pretxnchangegroup' and |
331 if (hooktype == 'pretxnchangegroup' and |
315 source not in ui.configlist('acl', 'sources')): |
332 source not in ui.configlist('acl', 'sources')): |