changeset 5923:f39110afc039

hgweb: fix a stupid KeyError introduced in a0e20a5eba3c Thanks to Christian Ebert for finding this. Also added a test to prevent this from happening again.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Tue, 22 Jan 2008 09:11:08 +0100
parents df7f66f290b9
children b8009718a211
files mercurial/hgweb/hgweb_mod.py tests/test-hgweb-commands tests/test-hgweb-commands.out
diffstat 3 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Tue Jan 22 09:11:06 2008 +0100
+++ b/mercurial/hgweb/hgweb_mod.py	Tue Jan 22 09:11:08 2008 +0100
@@ -212,7 +212,7 @@
                     req.form['cmd'] = [tmpl.cache['default']]
                     cmd = req.form['cmd'][0]
 
-                if cmd == 'file' and 'raw' in req.form['style']:
+                if cmd == 'file' and 'raw' in req.form.get('style', []):
                     webcommands.rawfile(self, req, tmpl)
                 else:
                     getattr(webcommands, cmd)(self, req, tmpl)
--- a/tests/test-hgweb-commands	Tue Jan 22 09:11:06 2008 +0100
+++ b/tests/test-hgweb-commands	Tue Jan 22 09:11:08 2008 +0100
@@ -27,6 +27,7 @@
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/file/1/foo/?style=raw'
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/annotate/1/foo/?style=raw'
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/file/1/?style=raw'
+"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/file/1/foo' | sed "s/[0-9]* years/many years/"
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/filediff/1/foo/?style=raw'
 
 echo % Overviews
Binary file tests/test-hgweb-commands.out has changed