# HG changeset patch # User Ollivier Robert # Date 1125211388 25200 # Node ID df25ee778ac2283cbedc272b73e2e32e77b76db4 # Parent 7fca9752d9459c1b5e14d01f62b3fef5d62da270 Handle a nonexistent repository with a 404 error. Based on changeset 62ea868cafbfa3acb7e5dba6982ecb46a1637246 from Vincent Wagelaar in http://hannibal.lr-s.tudelft.nl/~vincent/fcgi diff -r 7fca9752d945 -r df25ee778ac2 mercurial/hgweb.py --- 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)