Mercurial > hg-stable
changeset 1120:df25ee778ac2
Handle a nonexistent repository with a 404 error.
Based on changeset 62ea868cafbfa3acb7e5dba6982ecb46a1637246 from
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
in http://hannibal.lr-s.tudelft.nl/~vincent/fcgi
author | Ollivier Robert <roberto@keltia.freenix.fr> |
---|---|
date | Sat, 27 Aug 2005 23:43:08 -0700 |
parents | 7fca9752d945 |
children | 14a69c4988cd |
files | mercurial/hgweb.py |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb.py Sat Aug 27 23:42:51 2005 -0700 +++ b/mercurial/hgweb.py Sat Aug 27 23:43:08 2005 -0700 @@ -69,6 +69,10 @@ sys.stdout.write('Content-length: %d\n' % size) sys.stdout.write('\n') +def httpnotfound(filename): + sys.stdout.write("Status: 404\r\n\r\n") + sys.stdout.write("File not found: (%s)" % (filename, )) + def write(*things): for thing in things: if hasattr(thing, "__iter__"): @@ -938,12 +942,17 @@ except: virtual = "" - if virtual[1:]: - if self.cp.has_option("paths", virtual[1:]): - real = self.cp.get("paths", virtual[1:]) + virtual = virtual.strip('/') + + if len(virtual): + try: + real = self.cp.get("paths", virtual) h = hgweb(real) h.run() return + except NoOptionError: + httpnotfound(virtual) + return def header(**map): yield tmpl("header", **map)