diff mercurial/hgweb/hgweb_mod.py @ 36801:66de4555cefd

wireproto: formalize permissions checking as part of protocol interface Per the inline comment desiring to formalize permissions checking in the protocol interface, we do that. I'm not convinced this is the best way to go about things. I would love for there to e.g. be a better exception for denoting permissions problems. But it does feel strictly better than snipping attributes on the proto instance. Differential Revision: https://phab.mercurial-scm.org/D2719
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 07 Mar 2018 16:18:52 -0800
parents 0b18604db95e
children 7fc80c982656
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Wed Mar 07 16:02:24 2018 -0800
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Mar 07 16:18:52 2018 -0800
@@ -350,18 +350,15 @@
 
         # Route it to a wire protocol handler if it looks like a wire protocol
         # request.
-        protohandler = wireprotoserver.parsehttprequest(rctx.repo, req, query)
+        protohandler = wireprotoserver.parsehttprequest(rctx, req, query,
+                                                        self.check_perm)
 
         if protohandler:
             try:
                 if query:
                     raise ErrorResponse(HTTP_NOT_FOUND)
 
-                # TODO fold this into parsehttprequest
-                checkperm = lambda op: self.check_perm(rctx, req, op)
-                protohandler['proto'].checkperm = checkperm
-
-                return protohandler['dispatch'](checkperm)
+                return protohandler['dispatch']()
             except ErrorResponse as inst:
                 return protohandler['handleerror'](inst)