Mercurial > hg
comparison hgext/acl.py @ 16956:c49cf339b5bb
acl: use of "!" prefix in user or group names
The "!" prefix allows you to prevent anyone except a given user or group to push
changesets in a given branch or path.
This patch enables a use case suggested by a user (Julien Bonnet):
There's a branch that only a given user (or group) should be able to push to,
and you don't want to restrict access to any other branch that may be created.
With the "!" prefix, you simply deny access to "!givenuser" (or "!@givengroup").
author | Elifarley Callado Coelho Cruz |
---|---|
date | Mon, 28 May 2012 19:45:15 -0300 |
parents | 363bde4224c8 |
children | d7b608149f6c |
comparison
equal
deleted
inserted
replaced
16955:92e1c64ba0d4 | 16956:c49cf339b5bb |
---|---|
172 | 172 |
173 if usersorgroups == '*': | 173 if usersorgroups == '*': |
174 return True | 174 return True |
175 | 175 |
176 for ug in usersorgroups.replace(',', ' ').split(): | 176 for ug in usersorgroups.replace(',', ' ').split(): |
177 if user == ug or ug.startswith('@') and user in _getusers(ui, ug[1:]): | 177 |
178 if ug.startswith('!'): | |
179 # Test for excluded user or group. Format: | |
180 # if ug is a user name: !username | |
181 # if ug is a group name: !@groupname | |
182 ug = ug[1:] | |
183 if not ug.startswith('@') and user != ug \ | |
184 or ug.startswith('@') and user not in _getusers(ui, ug[1:]): | |
185 return True | |
186 | |
187 # Test for user or group. Format: | |
188 # if ug is a user name: username | |
189 # if ug is a group name: @groupname | |
190 elif user == ug \ | |
191 or ug.startswith('@') and user in _getusers(ui, ug[1:]): | |
178 return True | 192 return True |
179 | 193 |
180 return False | 194 return False |
181 | 195 |
182 def buildmatch(ui, repo, user, key): | 196 def buildmatch(ui, repo, user, key): |