hgweb: remove one-off routing for file?style=raw
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 10 Mar 2018 15:37:29 -0800
changeset 36878 89002d07a114
parent 36877 9fc3d814646e
child 36879 98baf8dea553
hgweb: remove one-off routing for file?style=raw Now that both functions are using the same API, we can unify how the command is called and perform command-specific behavior in the command itself instead of in the high-level router. Differential Revision: https://phab.mercurial-scm.org/D2788
mercurial/hgweb/hgweb_mod.py
mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/hgweb_mod.py	Sat Mar 10 20:36:34 2018 -0800
+++ b/mercurial/hgweb/hgweb_mod.py	Sat Mar 10 15:37:29 2018 -0800
@@ -399,12 +399,6 @@
             if cmd not in webcommands.__all__:
                 msg = 'no such method: %s' % cmd
                 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
-            elif cmd == 'file' and req.qsparams.get('style') == 'raw':
-                res.status = '200 Script output follows'
-                res.headers['Content-Type'] = ctype
-                content = webcommands.rawfile(rctx, wsgireq, tmpl)
-                assert content is res
-                return res.sendresponse()
             else:
                 # Set some globals appropriate for web handlers. Commands can
                 # override easily enough.
--- a/mercurial/hgweb/webcommands.py	Sat Mar 10 20:36:34 2018 -0800
+++ b/mercurial/hgweb/webcommands.py	Sat Mar 10 15:37:29 2018 -0800
@@ -186,6 +186,9 @@
     If ``path`` is not defined, information about the root directory will
     be rendered.
     """
+    if web.req.qsparams.get('style') == 'raw':
+        return rawfile(web, req, tmpl)
+
     path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', ''))
     if not path:
         return manifest(web, req, tmpl)