mercurial/hgweb/common.py
changeset 5563 d61fea133f2d
parent 5561 22713dce19f6
child 5760 0145f9afb0e7
--- a/mercurial/hgweb/common.py	Wed Nov 28 08:39:05 2007 -0800
+++ b/mercurial/hgweb/common.py	Wed Nov 28 09:39:17 2007 -0800
@@ -12,11 +12,18 @@
     def __init__(self, code, message=None):
         Exception.__init__(self)
         self.code = code
-        if message is None:
-            from httplib import responses
-            self.message = responses.get(code, 'Error')
+        if message:
+            self.message = message
         else:
-            self.message = message
+            self.message = _statusmessage(code)
+
+def _statusmessage(code):
+    from BaseHTTPServer import BaseHTTPRequestHandler
+    responses = BaseHTTPRequestHandler.responses
+    return responses.get(code, ('Error', 'Unknown error'))[0]
+    
+def statusmessage(code):
+    return '%d %s' % (code, _statusmessage(code))
 
 def get_mtime(repo_path):
     store_path = os.path.join(repo_path, ".hg")