Patchwork D2780: hgweb: set variables in qsparams

login
register
mail settings
Submitter phabricator
Date March 10, 2018, 8:57 p.m.
Message ID <differential-rev-PHID-DREV-ts5nrhqaomjq6cs5p6kc-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29272/
State Superseded
Headers show

Comments

phabricator - March 10, 2018, 8:57 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We currently mutate wsgireq.form in a few places. Since it is
  independent from req.qsparams, we will need to make changes on
  req.qsparams as well before consumers can use qsparams. So let's
  do that.
  
  Eventually, we'll delete wsgireq.form and all references to it.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2780

AFFECTED FILES
  mercurial/hgweb/hgweb_mod.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

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
@@ -342,15 +342,22 @@ 
             # avoid accepting e.g. style parameter as command
             if util.safehasattr(webcommands, cmd):
                 wsgireq.form['cmd'] = [cmd]
+                req.qsparams['cmd'] = cmd
 
             if cmd == 'static':
                 wsgireq.form['file'] = ['/'.join(args)]
+                req.qsparams['file'] = '/'.join(args)
             else:
                 if args and args[0]:
                     node = args.pop(0).replace('%2F', '/')
                     wsgireq.form['node'] = [node]
+                    req.qsparams['node'] = node
                 if args:
                     wsgireq.form['file'] = args
+                    if 'file' in req.qsparams:
+                        del req.qsparams['file']
+                    for a in args:
+                        req.qsparams.add('file', a)
 
             ua = req.headers.get('User-Agent', '')
             if cmd == 'rev' and 'mercurial' in ua:
@@ -362,7 +369,9 @@ 
                     ext = spec[2]
                     if fn.endswith(ext):
                         wsgireq.form['node'] = [fn[:-len(ext)]]
+                        req.qsparams['node'] = fn[:-len(next)]
                         wsgireq.form['type'] = [type_]
+                        req.qsparams['type'] = type_
         else:
             cmd = wsgireq.form.get('cmd', [''])[0]
 
@@ -379,6 +388,7 @@ 
 
             if cmd == '':
                 wsgireq.form['cmd'] = [tmpl.cache['default']]
+                req.qsparams['cmd'] = tmpl.cache['default']
                 cmd = wsgireq.form['cmd'][0]
 
             # Don't enable caching if using a CSP nonce because then it wouldn't