diff mercurial/wireproto.py @ 36809: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 5bc7ff103081
line wrap: on
line diff
--- a/mercurial/wireproto.py	Wed Mar 07 16:02:24 2018 -0800
+++ b/mercurial/wireproto.py	Wed Mar 07 16:18:52 2018 -0800
@@ -731,13 +731,10 @@
                 vals[unescapearg(n)] = unescapearg(v)
         func, spec = commands[op]
 
-        # If the protocol supports permissions checking, perform that
-        # checking on each batched command.
-        # TODO formalize permission checking as part of protocol interface.
-        if util.safehasattr(proto, 'checkperm'):
-            perm = commands[op].permission
-            assert perm in ('push', 'pull')
-            proto.checkperm(perm)
+        # Validate that client has permissions to perform this command.
+        perm = commands[op].permission
+        assert perm in ('push', 'pull')
+        proto.checkperm(perm)
 
         if spec:
             keys = spec.split()