access.py
changeset 24 9f8e11ede780
parent 23 9fa62cfd2821
equal deleted inserted replaced
23:9fa62cfd2821 24:9f8e11ede780
    28     def allow(self, node):
    28     def allow(self, node):
    29         '''return if access allowed, raise exception if not.'''
    29         '''return if access allowed, raise exception if not.'''
    30         ctx = self.repo.changectx(node)
    30         ctx = self.repo.changectx(node)
    31         branch = ctx.branch()
    31         branch = ctx.branch()
    32         if not self.rules.allow("write", branch=branch, file=None):
    32         if not self.rules.allow("write", branch=branch, file=None):
    33             self.ui.debug(_('%s: user %s not allowed on branch %s\n') %
       
    34                 (__name__, self.user, branch))
       
    35             return False
    33             return False
    36         for f in ctx.files():
    34         for f in ctx.files():
    37             if not self.rules.allow("write", branch=branch, file=f):
    35             if not self.rules.allow("write", branch=branch, file=f):
    38                 self.ui.debug(_('%s: user %s not allowed on %s\n') %
       
    39                               (__name__, self.user, f))
       
    40                 return False
    36                 return False
    41         self.ui.debug(_('%s: allowing changeset %s\n') % (__name__, short(node)))
    37         self.ui.debug(_('%s: allowing changeset %s\n') % (__name__, short(node)))
    42         return True
    38         return True
    43 
    39 
    44     def check(self, node):
    40     def check(self, node):
    45         if not allow(self, node):
    41         if not self.allow(node):
    46             raise util.Abort(_('%s: access denied for changeset %s') %
    42             raise util.Abort(_('%s: access denied for changeset %s') %
    47                 (__name__, short(node)))
    43                 (__name__, short(node)))
    48 
    44 
    49         
    45         
    50 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    46 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):