Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE-12:Update
mercurial.7061
hg-r36753.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hg-r36753.patch of Package mercurial.7061
# HG changeset patch # User Gregory Szorc <gregory.szorc@gmail.com> # Date 1519181619 28800 # Tue Feb 20 18:53:39 2018 -0800 # Branch stable # Node ID 742ce6fbc109cc1d0944292e73fcaa1c7291b90d # Parent bbd4027b019b07a83fd7d76ee81c8f152f7916df 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. --- hgext/largefiles/uisetup.py | 8 ++++---- mercurial/hgweb/hgweb_mod.py | 13 +++---------- mercurial/wireproto.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 14 deletions(-) --- a/hgext/largefiles/uisetup.py +++ b/hgext/largefiles/uisetup.py @@ -11,7 +11,7 @@ from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \ httppeer, merge, scmutil, sshpeer, wireproto, revset from mercurial.i18n import _ -from mercurial.hgweb import hgweb_mod, webcommands +from mercurial.hgweb import webcommands from mercurial.subrepo import hgsubrepo import overrides @@ -134,9 +134,9 @@ def uisetup(ui): # make putlfile behave the same as push and {get,stat}lfile behave # the same as pull w.r.t. permissions checks - hgweb_mod.perms['putlfile'] = 'push' - hgweb_mod.perms['getlfile'] = 'pull' - hgweb_mod.perms['statlfile'] = 'pull' + wireproto.permissions['putlfile'] = 'push' + wireproto.permissions['getlfile'] = 'pull' + wireproto.permissions['statlfile'] = 'pull' extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath) --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -7,7 +7,7 @@ # GNU General Public License version 2 or any later version. import os -from mercurial import ui, hg, hook, error, encoding, templater, util, repoview +from mercurial import ui, hg, hook, error, encoding, templater, util, wireproto, repoview from mercurial.templatefilters import websub from mercurial.i18n import _ from common import get_stat, ErrorResponse, permhooks, caching @@ -16,15 +16,8 @@ from common import HTTP_NOT_FOUND, HTTP_ from request import wsgirequest import webcommands, protocol, webutil, re -perms = { - 'changegroup': 'pull', - 'changegroupsubset': 'pull', - 'getbundle': 'pull', - 'stream_out': 'pull', - 'listkeys': 'pull', - 'unbundle': 'push', - 'pushkey': 'push', -} +# Aliased for API compatibility. +perms = wireproto.permissions def makebreadcrumb(url, prefix=''): '''Return a 'URL breadcrumb' list --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -11,6 +11,11 @@ from node import bin, hex import changegroup as changegroupmod import peer, error, encoding, util, store +# Maps wire protocol name to operation type. This is used for permissions +# checking. All defined @wireiprotocommand should have an entry in this +# dict. +permissions = {} + # abstract batching support class future(object): @@ -663,3 +668,11 @@ commands = { 'stream_out': (stream, ''), 'unbundle': (unbundle, 'heads'), } + +permissions['changegroup'] = 'pull' +permissions['changegroupsubset'] = 'pull' +permissions['getbundle'] = 'pull' +permissions['listkeys'] = 'pull' +permissions['pushkey'] = 'push' +permissions['stream_out'] = 'pull' +permissions['unbundle'] = 'push'
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor