indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY The "style" parameter is kind of wonky because it is explicitly set and has lookups in random locations. Let's port it to qsparams first because it isn't straightforward. There is subtle change in behavior. But I don't think it is worth calling out in a BC. Our multidict's __getitem__ returns the last set value for a key, not the first. So if the query string set a variable multiple times, before we would get the first value and now we would get the last value. It makes no sense to specify these things multiple times. And I think last write wins is more sensible than first write wins. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2779 AFFECTED FILES mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/webcommands.py mercurial/hgweb/webutil.py CHANGE DETAILS diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -438,8 +438,8 @@ basectx = ctx.p1() style = web.config('web', 'style') - if 'style' in req.form: - style = req.form['style'][0] + if 'style' in req.req.qsparams: + style = req.req.qsparams['style'] diff = diffs(web, tmpl, ctx, basectx, None, style) diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -762,8 +762,8 @@ basectx = ctx.p1() style = web.config('web', 'style') - if 'style' in req.form: - style = req.form['style'][0] + if 'style' in req.req.qsparams: + style = req.req.qsparams['style'] diffs = webutil.diffs(web, tmpl, ctx, basectx, [path], style) if fctx is not None: @@ -1011,8 +1011,8 @@ entries = [] diffstyle = web.config('web', 'style') - if 'style' in req.form: - diffstyle = req.form['style'][0] + if 'style' in req.req.qsparams: + diffstyle = req.req.qsparams['style'] def diff(fctx, linerange=None): ctx = fctx.changectx() diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -510,7 +510,7 @@ url += '/' vars = {} - styles, (style, mapfile) = hgweb_mod.getstyle(wsgireq, config, + styles, (style, mapfile) = hgweb_mod.getstyle(wsgireq.req, config, self.templatepath) if style == styles[0]: vars['style'] = style diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -53,9 +53,8 @@ )) def getstyle(req, configfn, templatepath): - fromreq = req.form.get('style', [None])[0] styles = ( - fromreq, + req.qsparams.get('style', None), configfn('web', 'style'), 'paper', ) @@ -160,7 +159,7 @@ # figure out which style to use vars = {} - styles, (style, mapfile) = getstyle(wsgireq, self.config, + styles, (style, mapfile) = getstyle(wsgireq.req, self.config, self.templatepath) if style == styles[0]: vars['style'] = style @@ -337,7 +336,7 @@ cmd = args.pop(0) style = cmd.rfind('-') if style != -1: - wsgireq.form['style'] = [cmd[:style]] + req.qsparams['style'] = cmd[:style] cmd = cmd[style + 1:] # avoid accepting e.g. style parameter as command @@ -355,7 +354,7 @@ ua = req.headers.get('User-Agent', '') if cmd == 'rev' and 'mercurial' in ua: - wsgireq.form['style'] = ['raw'] + req.qsparams['style'] = 'raw' if cmd == 'archive': fn = wsgireq.form['node'][0] @@ -389,7 +388,7 @@ if cmd not in webcommands.__all__: msg = 'no such method: %s' % cmd raise ErrorResponse(HTTP_BAD_REQUEST, msg) - elif cmd == 'file' and 'raw' in wsgireq.form.get('style', []): + elif cmd == 'file' and req.qsparams.get('style') == 'raw': rctx.ctype = ctype content = webcommands.rawfile(rctx, wsgireq, tmpl) else: To: indygreg, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel