D2798: hgweb: use web.req instead of req.req

2018-03-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG66f62d120ba2: hgweb: use web.req instead of req.req 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2798?vs=6859=6934

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

AFFECTED FILES
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -93,16 +93,16 @@
 file will be shown. This form is equivalent to the ``filelog`` handler.
 """
 
-if req.req.qsparams.get('file'):
+if web.req.qsparams.get('file'):
 return filelog(web, req, tmpl)
 else:
 return changelog(web, req, tmpl)
 
 @webcommand('rawfile')
 def rawfile(web, req, tmpl):
 guessmime = web.configbool('web', 'guessmime')
 
-path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
+path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
 return manifest(web, req, tmpl)
 
@@ -187,7 +187,7 @@
 if web.req.qsparams.get('style') == 'raw':
 return rawfile(web, req, tmpl)
 
-path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
+path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
 return manifest(web, req, tmpl)
 try:
@@ -198,7 +198,7 @@
 except ErrorResponse:
 raise inst
 
-def _search(web, req, tmpl):
+def _search(web, tmpl):
 MODE_REVISION = 'rev'
 MODE_KEYWORD = 'keyword'
 MODE_REVSET = 'revset'
@@ -303,11 +303,11 @@
 if count >= revcount:
 break
 
-query = req.req.qsparams['rev']
+query = web.req.qsparams['rev']
 revcount = web.maxchanges
-if 'revcount' in req.req.qsparams:
+if 'revcount' in web.req.qsparams:
 try:
-revcount = int(req.req.qsparams.get('revcount', revcount))
+revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
 tmpl.defaults['sessionvars']['revcount'] = revcount
 except ValueError:
@@ -322,7 +322,7 @@
 
 mode, funcarg = getsearchmode(query)
 
-if 'forcekw' in req.req.qsparams:
+if 'forcekw' in web.req.qsparams:
 showforcekw = ''
 showunforcekw = searchfuncs[mode][1]
 mode = MODE_KEYWORD
@@ -381,11 +381,11 @@
 """
 
 query = ''
-if 'node' in req.req.qsparams:
+if 'node' in web.req.qsparams:
 ctx = webutil.changectx(web.repo, req)
 symrev = webutil.symrevorshortnode(req, ctx)
-elif 'rev' in req.req.qsparams:
-return _search(web, req, tmpl)
+elif 'rev' in web.req.qsparams:
+return _search(web, tmpl)
 else:
 ctx = web.repo['tip']
 symrev = 'tip'
@@ -409,9 +409,9 @@
 else:
 revcount = web.maxchanges
 
-if 'revcount' in req.req.qsparams:
+if 'revcount' in web.req.qsparams:
 try:
-revcount = int(req.req.qsparams.get('revcount', revcount))
+revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
 tmpl.defaults['sessionvars']['revcount'] = revcount
 except ValueError:
@@ -516,13 +516,13 @@
 
 The ``manifest`` template will be rendered for this handler.
 """
-if 'node' in req.req.qsparams:
+if 'node' in web.req.qsparams:
 ctx = webutil.changectx(web.repo, req)
 symrev = webutil.symrevorshortnode(req, ctx)
 else:
 ctx = web.repo['tip']
 symrev = 'tip'
-path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
+path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 mf = ctx.manifest()
 node = ctx.node()
 
@@ -806,7 +806,7 @@
 fctx = webutil.filectx(web.repo, req)
 except LookupError:
 ctx = webutil.changectx(web.repo, req)
-path = webutil.cleanpath(web.repo, req.req.qsparams['file'])
+path = webutil.cleanpath(web.repo, web.req.qsparams['file'])
 if path not in ctx.files():
 raise
 
@@ -816,8 +816,8 @@
 basectx = ctx.p1()
 
 style = web.config('web', 'style')
-if 'style' in req.req.qsparams:
-style = req.req.qsparams['style']
+if 'style' in web.req.qsparams:
+style = web.req.qsparams['style']
 
 diffs = webutil.diffs(web, tmpl, ctx, basectx, [path], style)
 if fctx is not None:
@@ -857,13 +857,13 @@
 The ``filecomparison`` template is rendered.
 """
 ctx = webutil.changectx(web.repo, req)
-if 'file' not in req.req.qsparams:
+if 'file' not in web.req.qsparams:
 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
-path = webutil.cleanpath(web.repo, req.req.qsparams['file'])
+path = webutil.cleanpath(web.repo, 

D2798: hgweb: use web.req instead of req.req

2018-03-10 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We now have access to the modern request type on the
  requestcontext instance. Let's access it from there.
  
  While we're here, remove an unused argument from _search().

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -93,16 +93,16 @@
 file will be shown. This form is equivalent to the ``filelog`` handler.
 """
 
-if req.req.qsparams.get('file'):
+if web.req.qsparams.get('file'):
 return filelog(web, req, tmpl)
 else:
 return changelog(web, req, tmpl)
 
 @webcommand('rawfile')
 def rawfile(web, req, tmpl):
 guessmime = web.configbool('web', 'guessmime')
 
-path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
+path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
 return manifest(web, req, tmpl)
 
@@ -187,7 +187,7 @@
 if web.req.qsparams.get('style') == 'raw':
 return rawfile(web, req, tmpl)
 
-path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
+path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
 return manifest(web, req, tmpl)
 try:
@@ -198,7 +198,7 @@
 except ErrorResponse:
 raise inst
 
-def _search(web, req, tmpl):
+def _search(web, tmpl):
 MODE_REVISION = 'rev'
 MODE_KEYWORD = 'keyword'
 MODE_REVSET = 'revset'
@@ -303,11 +303,11 @@
 if count >= revcount:
 break
 
-query = req.req.qsparams['rev']
+query = web.req.qsparams['rev']
 revcount = web.maxchanges
-if 'revcount' in req.req.qsparams:
+if 'revcount' in web.req.qsparams:
 try:
-revcount = int(req.req.qsparams.get('revcount', revcount))
+revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
 tmpl.defaults['sessionvars']['revcount'] = revcount
 except ValueError:
@@ -322,7 +322,7 @@
 
 mode, funcarg = getsearchmode(query)
 
-if 'forcekw' in req.req.qsparams:
+if 'forcekw' in web.req.qsparams:
 showforcekw = ''
 showunforcekw = searchfuncs[mode][1]
 mode = MODE_KEYWORD
@@ -381,11 +381,11 @@
 """
 
 query = ''
-if 'node' in req.req.qsparams:
+if 'node' in web.req.qsparams:
 ctx = webutil.changectx(web.repo, req)
 symrev = webutil.symrevorshortnode(req, ctx)
-elif 'rev' in req.req.qsparams:
-return _search(web, req, tmpl)
+elif 'rev' in web.req.qsparams:
+return _search(web, tmpl)
 else:
 ctx = web.repo['tip']
 symrev = 'tip'
@@ -409,9 +409,9 @@
 else:
 revcount = web.maxchanges
 
-if 'revcount' in req.req.qsparams:
+if 'revcount' in web.req.qsparams:
 try:
-revcount = int(req.req.qsparams.get('revcount', revcount))
+revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
 tmpl.defaults['sessionvars']['revcount'] = revcount
 except ValueError:
@@ -516,13 +516,13 @@
 
 The ``manifest`` template will be rendered for this handler.
 """
-if 'node' in req.req.qsparams:
+if 'node' in web.req.qsparams:
 ctx = webutil.changectx(web.repo, req)
 symrev = webutil.symrevorshortnode(req, ctx)
 else:
 ctx = web.repo['tip']
 symrev = 'tip'
-path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
+path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 mf = ctx.manifest()
 node = ctx.node()
 
@@ -806,7 +806,7 @@
 fctx = webutil.filectx(web.repo, req)
 except LookupError:
 ctx = webutil.changectx(web.repo, req)
-path = webutil.cleanpath(web.repo, req.req.qsparams['file'])
+path = webutil.cleanpath(web.repo, web.req.qsparams['file'])
 if path not in ctx.files():
 raise
 
@@ -816,8 +816,8 @@
 basectx = ctx.p1()
 
 style = web.config('web', 'style')
-if 'style' in req.req.qsparams:
-style = req.req.qsparams['style']
+if 'style' in web.req.qsparams:
+style = web.req.qsparams['style']
 
 diffs = webutil.diffs(web, tmpl, ctx, basectx, [path], style)
 if fctx is not None:
@@ -857,13 +857,13 @@
 The ``filecomparison`` template is rendered.
 """
 ctx = webutil.changectx(web.repo, req)
-if 'file' not in req.req.qsparams:
+if 'file' not in web.req.qsparams:
 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
-path = webutil.cleanpath(web.repo, req.req.qsparams['file'])
+path =