Mercurial > hg
comparison mercurial/wireprotoserver.py @ 36877:02bea04b4c54
hgweb: transition permissions hooks to modern request type (API)
We're trying to remove ``wsgirequest``. The permissions hooks don't
do anything they can't do with our new request type. So let's
pass that in.
This was the last use of ``wsgirequest`` in the wire protocol code!
.. api::
hgweb.hgweb_mod.permhooks no longer take a ``wsgirequest`` instance
as an argument.
Differential Revision: https://phab.mercurial-scm.org/D2793
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 10 Mar 2018 18:19:27 -0800 |
parents | a755fd3b7146 |
children | 1cfef5693203 |
comparison
equal
deleted
inserted
replaced
36876:97f44b0720e2 | 36877:02bea04b4c54 |
---|---|
146 # there are no other known users, so with any luck we can discard this | 146 # there are no other known users, so with any luck we can discard this |
147 # hook if remotefilelog becomes a first-party extension. | 147 # hook if remotefilelog becomes a first-party extension. |
148 def iscmd(cmd): | 148 def iscmd(cmd): |
149 return cmd in wireproto.commands | 149 return cmd in wireproto.commands |
150 | 150 |
151 def handlewsgirequest(rctx, wsgireq, req, res, checkperm): | 151 def handlewsgirequest(rctx, req, res, checkperm): |
152 """Possibly process a wire protocol request. | 152 """Possibly process a wire protocol request. |
153 | 153 |
154 If the current request is a wire protocol request, the request is | 154 If the current request is a wire protocol request, the request is |
155 processed by this function. | 155 processed by this function. |
156 | 156 |
157 ``wsgireq`` is a ``wsgirequest`` instance. | |
158 ``req`` is a ``parsedrequest`` instance. | 157 ``req`` is a ``parsedrequest`` instance. |
159 ``res`` is a ``wsgiresponse`` instance. | 158 ``res`` is a ``wsgiresponse`` instance. |
160 | 159 |
161 Returns a bool indicating if the request was serviced. If set, the caller | 160 Returns a bool indicating if the request was serviced. If set, the caller |
162 should stop processing the request, as a response has already been issued. | 161 should stop processing the request, as a response has already been issued. |
195 # is mostly for BC for now. | 194 # is mostly for BC for now. |
196 res.setbodybytes('0\n%s\n' % b'Not Found') | 195 res.setbodybytes('0\n%s\n' % b'Not Found') |
197 return True | 196 return True |
198 | 197 |
199 proto = httpv1protocolhandler(req, repo.ui, | 198 proto = httpv1protocolhandler(req, repo.ui, |
200 lambda perm: checkperm(rctx, wsgireq, perm)) | 199 lambda perm: checkperm(rctx, req, perm)) |
201 | 200 |
202 # The permissions checker should be the only thing that can raise an | 201 # The permissions checker should be the only thing that can raise an |
203 # ErrorResponse. It is kind of a layer violation to catch an hgweb | 202 # ErrorResponse. It is kind of a layer violation to catch an hgweb |
204 # exception here. So consider refactoring into a exception type that | 203 # exception here. So consider refactoring into a exception type that |
205 # is associated with the wire protocol. | 204 # is associated with the wire protocol. |