Patchwork D2779: hgweb: use our new request object for "style" parameter

login
register
mail settings
Submitter phabricator
Date March 12, 2018, 9:33 p.m.
Message ID <06d238da9acc1839b2de81436aa89b06@localhost.localdomain>
Download mbox | patch
Permalink /patch/29363/
State Not Applicable
Headers show

Comments

phabricator - March 12, 2018, 9:33 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1a1972b1a1ff: hgweb: use our new request object for &quot;style&quot; parameter (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2779?vs=6839&id=6915

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




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

Patch

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: