author | Paul Crowley <paul@lshift.net> |
Fri, 17 Dec 2010 23:01:52 +0000 | |
branch | debian |
changeset 280 | 9a171c093f61 |
parent 242 | 03d8f07230b3 |
child 311 | 3cbde66305e4 |
permissions | -rw-r--r-- |
242
03d8f07230b3
Tidy up file prologues; move credits to CREDITS
Paul Crowley <paul@lshift.net>
parents:
241
diff
changeset
|
1 |
"""Mercurial access control hook""" |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
2 |
|
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
3 |
from mercurial.i18n import _ |
51 | 4 |
import mercurial.util |
53 | 5 |
import mercurial.node |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
6 |
|
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
7 |
import os |
67
fd16d9a1234b
Put .py files into a directory of their own
Paul Crowley <paul@lshift.net>
parents:
62
diff
changeset
|
8 |
from mercurialserver import ruleset |
fd16d9a1234b
Put .py files into a directory of their own
Paul Crowley <paul@lshift.net>
parents:
62
diff
changeset
|
9 |
from mercurialserver import changes |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
10 |
|
241
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
11 |
def allow(ctx): |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
12 |
branch = ctx.branch() |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
13 |
if not ruleset.rules.allow("write", branch=branch, file=None): |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
14 |
return False |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
15 |
for f in ctx.files(): |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
16 |
if not ruleset.rules.allow("write", branch=branch, file=f): |
20
f4daa224dc7e
Add support for locking by branch, and document breaking in.
Paul Crowley <paul@ciphergoth.org>
parents:
18
diff
changeset
|
17 |
return False |
241
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
18 |
return True |
20
f4daa224dc7e
Add support for locking by branch, and document breaking in.
Paul Crowley <paul@ciphergoth.org>
parents:
18
diff
changeset
|
19 |
|
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
20 |
def hook(ui, repo, hooktype, node=None, source=None, **kwargs): |
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
21 |
if hooktype != 'pretxnchangegroup': |
51 | 22 |
raise mercurial.util.Abort(_('config error - hook type "%s" cannot stop ' |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
23 |
'incoming changesets') % hooktype) |
52
f9eb98bb0791
Encapsulate change finding with backwards compatibility
Paul Crowley <paul@lshift.net>
parents:
51
diff
changeset
|
24 |
for ctx in changes.changes(repo, node): |
241
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
25 |
if not allow(ctx): |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
26 |
raise mercurial.util.Abort(_('%s: access denied for changeset %s') % |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
27 |
(__name__, mercurial.node.short(ctx.node()))) |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
28 |