author | Paul Crowley <paul@lshift.net> |
Sat, 19 Dec 2009 10:46:42 +0000 | |
changeset 241 | 4af1e1ccf75b |
parent 77 | 8d14aac93b5d |
child 242 | 03d8f07230b3 |
permissions | -rw-r--r-- |
50
77d97aa18f29
update dates and copyright notices
Paul Crowley <paul@lshift.net>
parents:
41
diff
changeset
|
1 |
# Copyright 2008-2009 LShift Ltd |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
2 |
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
3 |
# |
18
538d6b198f4a
Big change to support file conditions; format of hg-ssh-access.conf
Paul Crowley <paul@lshift.net>
parents:
17
diff
changeset
|
4 |
# Authors: |
538d6b198f4a
Big change to support file conditions; format of hg-ssh-access.conf
Paul Crowley <paul@lshift.net>
parents:
17
diff
changeset
|
5 |
# Paul Crowley <paul@lshift.net> |
538d6b198f4a
Big change to support file conditions; format of hg-ssh-access.conf
Paul Crowley <paul@lshift.net>
parents:
17
diff
changeset
|
6 |
# Vadim Gelfer <vadim.gelfer@gmail.com> |
538d6b198f4a
Big change to support file conditions; format of hg-ssh-access.conf
Paul Crowley <paul@lshift.net>
parents:
17
diff
changeset
|
7 |
# |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
8 |
# This software may be used and distributed according to the terms |
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
9 |
# of the GNU General Public License, incorporated herein by reference. |
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
10 |
|
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
11 |
from mercurial.i18n import _ |
51 | 12 |
import mercurial.util |
53 | 13 |
import mercurial.node |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
14 |
|
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
15 |
import os |
67
fd16d9a1234b
Put .py files into a directory of their own
Paul Crowley <paul@lshift.net>
parents:
62
diff
changeset
|
16 |
from mercurialserver import ruleset |
fd16d9a1234b
Put .py files into a directory of their own
Paul Crowley <paul@lshift.net>
parents:
62
diff
changeset
|
17 |
from mercurialserver import changes |
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
18 |
|
241
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
19 |
def allow(ctx): |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
20 |
branch = ctx.branch() |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
21 |
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
|
22 |
return False |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
return False |
241
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
26 |
return True |
20
f4daa224dc7e
Add support for locking by branch, and document breaking in.
Paul Crowley <paul@ciphergoth.org>
parents:
18
diff
changeset
|
27 |
|
17
4c98440de851
Started work on acl.py replacement - currently broken.
Paul Crowley <paul@ciphergoth.org>
parents:
diff
changeset
|
28 |
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
|
29 |
if hooktype != 'pretxnchangegroup': |
51 | 30 |
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
|
31 |
'incoming changesets') % hooktype) |
52
f9eb98bb0791
Encapsulate change finding with backwards compatibility
Paul Crowley <paul@lshift.net>
parents:
51
diff
changeset
|
32 |
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
|
33 |
if not allow(ctx): |
4af1e1ccf75b
"Checker" class isn't doing any work, replace with function
Paul Crowley <paul@lshift.net>
parents:
77
diff
changeset
|
34 |
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
|
35 |
(__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
|
36 |