mercurial/hgweb/hgweb_mod.py
changeset 6149 b023915aa1bc
parent 6142 50a277e6ceae
child 6152 c050548307a4
--- a/mercurial/hgweb/hgweb_mod.py	Tue Feb 19 19:34:18 2008 -0300
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Feb 20 10:50:10 2008 +0100
@@ -199,35 +199,38 @@
                         req.form['node'] = [fn[:-len(ext)]]
                         req.form['type'] = [type_]
 
-        # actually process the request
+        # process this if it's a protocol request
+
+        cmd = req.form.get('cmd', [''])[0]
+        if cmd in protocol.__all__:
+            method = getattr(protocol, cmd)
+            method(self, req)
+            return
+
+        # process the web interface request
 
         try:
 
-            cmd = req.form.get('cmd', [''])[0]
-            if cmd in protocol.__all__:
-                method = getattr(protocol, cmd)
-                method(self, req)
-            else:
-                tmpl = self.templater(req)
-                ctype = tmpl('mimetype', encoding=self.encoding)
-                ctype = templater.stringify(ctype)
-                
-                if cmd == '':
-                    req.form['cmd'] = [tmpl.cache['default']]
-                    cmd = req.form['cmd'][0]
+            tmpl = self.templater(req)
+            ctype = tmpl('mimetype', encoding=self.encoding)
+            ctype = templater.stringify(ctype)
+
+            if cmd == '':
+                req.form['cmd'] = [tmpl.cache['default']]
+                cmd = req.form['cmd'][0]
 
-                if cmd not in webcommands.__all__:
-                    msg = 'No such method: %s' % cmd
-                    raise ErrorResponse(HTTP_BAD_REQUEST, msg)
-                elif cmd == 'file' and 'raw' in req.form.get('style', []):
-                    self.ctype = ctype
-                    content = webcommands.rawfile(self, req, tmpl)
-                else:
-                    content = getattr(webcommands, cmd)(self, req, tmpl)
-                    req.respond(HTTP_OK, ctype)
+            if cmd not in webcommands.__all__:
+                msg = 'No such method: %s' % cmd
+                raise ErrorResponse(HTTP_BAD_REQUEST, msg)
+            elif cmd == 'file' and 'raw' in req.form.get('style', []):
+                self.ctype = ctype
+                content = webcommands.rawfile(self, req, tmpl)
+            else:
+                content = getattr(webcommands, cmd)(self, req, tmpl)
+                req.respond(HTTP_OK, ctype)
 
-                req.write(content)
-                del tmpl
+            req.write(content)
+            del tmpl
 
         except revlog.LookupError, err:
             req.respond(HTTP_NOT_FOUND, ctype)