/usr/share/mercurial-server/mercurialserver/access.py is in mercurial-server 1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | """Mercurial access control hook"""
from mercurial.i18n import _
import mercurial.util
import mercurial.node
import os
from mercurialserver import ruleset
from mercurialserver import changes
def allow(ctx):
branch = ctx.branch()
if not ruleset.rules.allow("write", branch=branch, file=None):
return False
for f in ctx.files():
if not ruleset.rules.allow("write", branch=branch, file=f):
return False
return True
def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
if hooktype != 'pretxnchangegroup':
raise mercurial.util.Abort(_('config error - hook type "%s" cannot stop '
'incoming changesets') % hooktype)
for ctx in changes.changes(repo, node):
if not allow(ctx):
raise mercurial.util.Abort(_('%s: access denied for changeset %s') %
(__name__, mercurial.node.short(ctx.node())))
|