# HG changeset patch # User Dirkjan Ochtman # Date 2008-06-28 13:28:43 # Node ID 44c5157474e7c661028007e690e4ed22da5aea01 # Parent 39319a457ddac02e209461eb3d0ed2145ccc0106 hgweb: protocol requests are processed immediately This makes separation of interface/webcommands and protocol easier and will make http repos slightly faster because there's less overhead. 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 @@ -89,6 +89,16 @@ class hgweb(object): self.refresh() + # process this if it's a protocol request + # protocol bits don't need to create any URLs + # and the clients always use the old URL structure + + cmd = req.form.get('cmd', [''])[0] + if cmd and cmd in protocol.__all__: + method = getattr(protocol, cmd) + method(self, req) + return + # work with CGI variables to create coherent structure # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME @@ -120,8 +130,10 @@ class hgweb(object): cmd = cmd[style+1:] # avoid accepting e.g. style parameter as command - if hasattr(webcommands, cmd) or hasattr(protocol, cmd): + if hasattr(webcommands, cmd): req.form['cmd'] = [cmd] + else: + cmd = '' if args and args[0]: node = args.pop(0) @@ -139,14 +151,6 @@ class hgweb(object): req.form['node'] = [fn[:-len(ext)]] req.form['type'] = [type_] - # 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: diff --git a/tests/test-hgweb-commands b/tests/test-hgweb-commands --- a/tests/test-hgweb-commands +++ b/tests/test-hgweb-commands @@ -36,19 +36,19 @@ echo % Overviews "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/summary/?style=gitweb' | sed "s/[0-9]* years ago/long ago/g" echo % capabilities -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/capabilities' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities' echo % heads -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/heads' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=heads' echo % lookup -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/lookup/1' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=lookup&node=1' echo % branches -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/branches' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=branches' echo % changegroup -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/changegroup' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=changegroup' echo % stream_out -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/stream_out' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=stream_out' echo % failing unbundle, requires POST request -"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/unbundle' +"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=unbundle' echo % Static files "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/static/style.css'