Mercurial > hg
diff mercurial/hgweb/hgweb_mod.py @ 36753:742ce6fbc109 stable
wireproto: move command permissions dict out of hgweb_mod
The operation type associated with wire protocol commands is supposed
to be defined in a dictionary so it can be used for permissions
checking.
Since this metadata is closely associated with wire protocol commands
themselves, it makes sense to define it in the same module where
wire protocol commands are defined.
This commit moves hgweb_mod.perms to wireproto.PERMISSIONS and
updates most references in the code to use the new home. The old
symbol remains an alias for the new symbol. Tests pass with the
code pointing at the old symbol. So this should be API compatible
for extensions.
As part of the code move, we split up the assignment to the dict
so it is next to the @wireprotocommand. This reinforces that a
@wireprotocommand should have an entry in this dict.
In the future, we'll want to declare permissions as part of the
@wireprotocommand decorator. But this isn't appropriate for the
stable branch.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 20 Feb 2018 18:53:39 -0800 |
parents | da5d5ea7d696 |
children | ff4bc0ab6740 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Tue Feb 20 19:09:01 2018 -0800 +++ b/mercurial/hgweb/hgweb_mod.py Tue Feb 20 18:53:39 2018 -0800 @@ -36,6 +36,7 @@ templater, ui as uimod, util, + wireproto, ) from . import ( @@ -45,15 +46,8 @@ wsgicgi, ) -perms = { - 'changegroup': 'pull', - 'changegroupsubset': 'pull', - 'getbundle': 'pull', - 'stream_out': 'pull', - 'listkeys': 'pull', - 'unbundle': 'push', - 'pushkey': 'push', -} +# Aliased for API compatibility. +perms = wireproto.permissions archivespecs = util.sortdict(( ('zip', ('application/zip', 'zip', '.zip', None)),