D2800: hgweb: use templater on requestcontext instance

2018-03-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGece242db5000: hgweb: use templater on requestcontext 
instance (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2800?vs=6861=6936

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

AFFECTED FILES
  hgext/highlight/__init__.py
  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
@@ -95,23 +95,23 @@
 """
 
 if web.req.qsparams.get('file'):
-return filelog(web, req, tmpl)
+return filelog(web, req, None)
 else:
-return changelog(web, req, tmpl)
+return changelog(web, req, None)
 
 @webcommand('rawfile')
 def rawfile(web, req, tmpl):
 guessmime = web.configbool('web', 'guessmime')
 
 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 
 try:
 fctx = webutil.filectx(web.repo, req)
 except error.LookupError as inst:
 try:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 except ErrorResponse:
 raise inst
 
@@ -135,7 +135,7 @@
 web.res.setbodybytes(text)
 return web.res.sendresponse()
 
-def _filerevision(web, req, tmpl, fctx):
+def _filerevision(web, req, fctx):
 f = fctx.path()
 text = fctx.data()
 parity = paritygen(web.stripecount)
@@ -184,20 +184,20 @@
 be rendered.
 """
 if web.req.qsparams.get('style') == 'raw':
-return rawfile(web, req, tmpl)
+return rawfile(web, req, None)
 
 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 try:
-return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req))
+return _filerevision(web, req, webutil.filectx(web.repo, req))
 except error.LookupError as inst:
 try:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 except ErrorResponse:
 raise inst
 
-def _search(web, tmpl):
+def _search(web):
 MODE_REVISION = 'rev'
 MODE_KEYWORD = 'keyword'
 MODE_REVSET = 'revset'
@@ -290,14 +290,16 @@
 for ctx in searchfunc[0](funcarg):
 count += 1
 n = ctx.node()
-showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
-files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
+showtags = webutil.showtag(web.repo, web.tmpl, 'changelogtag', n)
+files = webutil.listfilediffs(web.tmpl, ctx.files(), n,
+  web.maxfiles)
 
-yield tmpl('searchentry',
-   parity=next(parity),
-   changelogtag=showtags,
-   files=files,
-   **pycompat.strkwargs(webutil.commonentry(web.repo, 
ctx)))
+yield web.tmpl(
+'searchentry',
+parity=next(parity),
+changelogtag=showtags,
+files=files,
+**pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
 
 if count >= revcount:
 break
@@ -308,14 +310,14 @@
 try:
 revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
-tmpl.defaults['sessionvars']['revcount'] = revcount
+web.tmpl.defaults['sessionvars']['revcount'] = revcount
 except ValueError:
 pass
 
-lessvars = copy.copy(tmpl.defaults['sessionvars'])
+lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
 lessvars['revcount'] = max(revcount // 2, 1)
 lessvars['rev'] = query
-morevars = copy.copy(tmpl.defaults['sessionvars'])
+morevars = copy.copy(web.tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 morevars['rev'] = query
 
@@ -382,7 +384,7 @@
 ctx = webutil.changectx(web.repo, req)
 symrev = webutil.symrevorshortnode(req, ctx)
 elif 'rev' in web.req.qsparams:
-return _search(web, tmpl)
+return _search(web)
 else:
 ctx = web.repo['tip']
 symrev = 'tip'
@@ -397,7 +399,7 @@
 if curcount > revcount + 1:
 break
 
-entry = webutil.changelistentry(web, web.repo[rev], tmpl)
+entry = webutil.changelistentry(web, web.repo[rev], web.tmpl)
 entry['parity'] = next(parity)
 yield entry
 
@@ -410,13 +412,13 @@
 try:
 revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
-

D2800: hgweb: use templater on requestcontext instance

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
  After this commit, all @webcommand function no longer use their
  "tmpl" argument. Instead, they use the templater attached to the
  requestcontext.
  
  This is the same exact object. So there should be no difference in
  behavior.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/highlight/__init__.py
  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
@@ -95,23 +95,23 @@
 """
 
 if web.req.qsparams.get('file'):
-return filelog(web, req, tmpl)
+return filelog(web, req, None)
 else:
-return changelog(web, req, tmpl)
+return changelog(web, req, None)
 
 @webcommand('rawfile')
 def rawfile(web, req, tmpl):
 guessmime = web.configbool('web', 'guessmime')
 
 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 
 try:
 fctx = webutil.filectx(web.repo, req)
 except error.LookupError as inst:
 try:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 except ErrorResponse:
 raise inst
 
@@ -135,7 +135,7 @@
 web.res.setbodybytes(text)
 return web.res.sendresponse()
 
-def _filerevision(web, req, tmpl, fctx):
+def _filerevision(web, req, fctx):
 f = fctx.path()
 text = fctx.data()
 parity = paritygen(web.stripecount)
@@ -184,20 +184,20 @@
 be rendered.
 """
 if web.req.qsparams.get('style') == 'raw':
-return rawfile(web, req, tmpl)
+return rawfile(web, req, None)
 
 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
 if not path:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 try:
-return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req))
+return _filerevision(web, req, webutil.filectx(web.repo, req))
 except error.LookupError as inst:
 try:
-return manifest(web, req, tmpl)
+return manifest(web, req, None)
 except ErrorResponse:
 raise inst
 
-def _search(web, tmpl):
+def _search(web):
 MODE_REVISION = 'rev'
 MODE_KEYWORD = 'keyword'
 MODE_REVSET = 'revset'
@@ -290,14 +290,16 @@
 for ctx in searchfunc[0](funcarg):
 count += 1
 n = ctx.node()
-showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
-files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
+showtags = webutil.showtag(web.repo, web.tmpl, 'changelogtag', n)
+files = webutil.listfilediffs(web.tmpl, ctx.files(), n,
+  web.maxfiles)
 
-yield tmpl('searchentry',
-   parity=next(parity),
-   changelogtag=showtags,
-   files=files,
-   **pycompat.strkwargs(webutil.commonentry(web.repo, 
ctx)))
+yield web.tmpl(
+'searchentry',
+parity=next(parity),
+changelogtag=showtags,
+files=files,
+**pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
 
 if count >= revcount:
 break
@@ -308,14 +310,14 @@
 try:
 revcount = int(web.req.qsparams.get('revcount', revcount))
 revcount = max(revcount, 1)
-tmpl.defaults['sessionvars']['revcount'] = revcount
+web.tmpl.defaults['sessionvars']['revcount'] = revcount
 except ValueError:
 pass
 
-lessvars = copy.copy(tmpl.defaults['sessionvars'])
+lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
 lessvars['revcount'] = max(revcount // 2, 1)
 lessvars['rev'] = query
-morevars = copy.copy(tmpl.defaults['sessionvars'])
+morevars = copy.copy(web.tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 morevars['rev'] = query
 
@@ -382,7 +384,7 @@
 ctx = webutil.changectx(web.repo, req)
 symrev = webutil.symrevorshortnode(req, ctx)
 elif 'rev' in web.req.qsparams:
-return _search(web, tmpl)
+return _search(web)
 else:
 ctx = web.repo['tip']
 symrev = 'tip'
@@ -397,7 +399,7 @@
 if curcount > revcount + 1:
 break
 
-entry = webutil.changelistentry(web, web.repo[rev], tmpl)
+entry = webutil.changelistentry(web, web.repo[rev], web.tmpl)
 entry['parity'] = next(parity)
 yield entry
 
@@ -410,13 +412,13 @@
 try:
 revcount =