src/access.py
changeset 52 f9eb98bb0791
parent 51 d87eeeae29a5
child 53 853444c5d393
equal deleted inserted replaced
51:d87eeeae29a5 52:f9eb98bb0791
    11 from mercurial.i18n import _
    11 from mercurial.i18n import _
    12 import mercurial.util
    12 import mercurial.util
    13 
    13 
    14 import os
    14 import os
    15 import ruleset
    15 import ruleset
       
    16 import changes
    16 
    17 
    17 class Checker(object):
    18 class Checker(object):
    18     '''acl checker.'''
    19     '''acl checker.'''
    19 
    20 
    20     def __init__(self, ui, repo):
    21     def __init__(self, ui, repo):
    38         '''return if access allowed, raise exception if not.'''
    39         '''return if access allowed, raise exception if not.'''
    39         if not self.allow(ctx):
    40         if not self.allow(ctx):
    40             raise mercurial.util.Abort(_('%s: access denied for changeset %s') %
    41             raise mercurial.util.Abort(_('%s: access denied for changeset %s') %
    41                 (__name__, ctx.short()))
    42                 (__name__, ctx.short()))
    42 
    43 
    43         
       
    44 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    44 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    45     if hooktype != 'pretxnchangegroup':
    45     if hooktype != 'pretxnchangegroup':
    46         raise mercurial.util.Abort(_('config error - hook type "%s" cannot stop '
    46         raise mercurial.util.Abort(_('config error - hook type "%s" cannot stop '
    47                            'incoming changesets') % hooktype)
    47                            'incoming changesets') % hooktype)
    48     c = Checker(ui, repo)
    48     c = Checker(ui, repo)
    49     start = repo.changectx(node).rev()
    49     for ctx in changes.changes(repo, node):
    50     end = repo.changelog.count()
    50         c.check(ctx)
    51     for rev in xrange(start, end):
       
    52         c.check(repo.changectx(rev))
       
    53 
    51