diff -r 538d6b198f4a -r f4daa224dc7e access.py --- a/access.py Tue Apr 22 09:46:29 2008 +0100 +++ b/access.py Tue Apr 22 10:13:39 2008 +0100 @@ -25,17 +25,28 @@ self.user = os.environ['REMOTE_USER'] self.rules = rules.Ruleset.readfile(os.environ['HG_ACCESS_RULES_FILE']) - def check(self, node): + def allow(self, node): '''return if access allowed, raise exception if not.''' - files = self.repo.changectx(node).files() - for f in files: - if not self.rules.allow("write", user=self.user, repo=self.repo_path, file=f): + ctx = self.repo.changectx(node) + branch = ctx.branch() + if not self.rules.allow("write", user=self.user, repo=self.repo_path, branch=self.branch, file=None): + self.ui.debug(_('%s: user %s not allowed on branch %s\n') % + (__name__, self.user, branch)) + return False + for f in ctx.files(): + if not self.rules.allow("write", user=self.user, repo=self.repo_path, branch=self.branch, file=f): self.ui.debug(_('%s: user %s not allowed on %s\n') % - (__name__, self.getuser(), f)) - raise util.Abort(_('%s: access denied for changeset %s') % - (__name__, short(node))) + (__name__, self.user, f)) + return False self.ui.debug(_('%s: allowing changeset %s\n') % (__name__, short(node))) + return True + def check(self, node): + if not allow(self, node): + raise util.Abort(_('%s: access denied for changeset %s') % + (__name__, short(node))) + + def hook(ui, repo, hooktype, node=None, source=None, **kwargs): if hooktype != 'pretxnchangegroup': raise util.Abort(_('config error - hook type "%s" cannot stop '