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 @@ -234,7 +234,7 @@ class hgweb(object): cmd = req.form['cmd'][0] if cmd not in webcommands.__all__: - msg = 'No such method: %s' % cmd + 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 @@ -248,7 +248,11 @@ class hgweb(object): except revlog.LookupError, err: req.respond(HTTP_NOT_FOUND, ctype) - req.write(tmpl('error', error='revision not found: %s' % err.name)) + if 'manifest' in err.message: + msg = str(err) + else: + msg = 'revision not found: %s' % err.name + req.write(tmpl('error', error=msg)) except (RepoError, revlog.RevlogError), inst: req.respond(HTTP_SERVER_ERROR, ctype) req.write(tmpl('error', error=str(inst))) @@ -737,7 +741,7 @@ class hgweb(object): files[short] = (f, n) if not files: - raise ErrorResponse(HTTP_NOT_FOUND, 'Path not found: ' + path) + raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) def filelist(**map): fl = files.keys() diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -34,10 +34,13 @@ def rawfile(web, req, tmpl): try: fctx = web.filectx(req) - except revlog.LookupError: - content = web.manifest(tmpl, web.changectx(req), path) - req.respond(HTTP_OK, web.ctype) - return content + except revlog.LookupError, inst: + try: + content = web.manifest(tmpl, web.changectx(req), path) + req.respond(HTTP_OK, web.ctype) + return content + except ErrorResponse: + raise inst path = fctx.path() text = fctx.data() @@ -53,10 +56,13 @@ def file(web, req, tmpl): if path: try: return web.filerevision(tmpl, web.filectx(req)) - except revlog.LookupError: + except revlog.LookupError, inst: pass - return web.manifest(tmpl, web.changectx(req), path) + try: + return web.manifest(tmpl, web.changectx(req), path) + except ErrorResponse: + raise inst def changelog(web, req, tmpl, shortlog = False): if 'node' in req.form: @@ -109,7 +115,7 @@ def archive(web, req, tmpl): web.configbool("web", "allow" + type_, False))): web.archive(tmpl, req, req.form['node'][0], type_) return [] - raise ErrorResponse(HTTP_NOT_FOUND, 'Unsupported archive type: %s' % type_) + raise ErrorResponse(HTTP_NOT_FOUND, 'unsupported archive type: %s' % type_) def static(web, req, tmpl): fname = req.form['file'][0] diff --git a/tests/test-hgweb b/tests/test-hgweb --- a/tests/test-hgweb +++ b/tests/test-hgweb @@ -27,6 +27,8 @@ echo % should give a 400 - bad command echo % should give a 404 - file does not exist "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw' echo % stop and restart kill `cat hg.pid` diff --git a/tests/test-hgweb.out b/tests/test-hgweb.out --- a/tests/test-hgweb.out +++ b/tests/test-hgweb.out @@ -59,14 +59,49 @@ error: revision not found: spam 400 -error: No such method: spam +error: no such method: spam % should give a 404 - file does not exist 404 Not Found -error: Path not found: bork/ +error: bork@2ef0ac749a14: not found in manifest +404 Not Found + + + +
+ + + + ++An error occurred while processing your request: +
++bork@2ef0ac749a14: not found in manifest +
+ + +