comparison mercurial/hgweb/hgweb_mod.py @ 7633:08cabecfa8a8

errors: move revlog errors - create error.py for exception classes to reduce demandloading - move revlog exceptions to it - change users to import error and drop revlog import if possible
author Matt Mackall <mpm@selenic.com>
date Sun, 11 Jan 2009 22:48:28 -0600
parents 3ccaefc84f45
children 1d54e2f6c0b7
comparison
equal deleted inserted replaced
7632:9626819b2e3d 7633:08cabecfa8a8
7 # of the GNU General Public License, incorporated herein by reference. 7 # of the GNU General Public License, incorporated herein by reference.
8 8
9 import os, mimetypes 9 import os, mimetypes
10 from mercurial.node import hex, nullid 10 from mercurial.node import hex, nullid
11 from mercurial.repo import RepoError 11 from mercurial.repo import RepoError
12 from mercurial import ui, hg, util, hook 12 from mercurial import ui, hg, util, hook, error
13 from mercurial import revlog, templater, templatefilters 13 from mercurial import templater, templatefilters
14 from common import get_mtime, style_map, ErrorResponse 14 from common import get_mtime, style_map, ErrorResponse
15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR 15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
16 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED 16 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED
17 from request import wsgirequest 17 from request import wsgirequest
18 import webcommands, protocol, webutil 18 import webcommands, protocol, webutil
183 content = getattr(webcommands, cmd)(self, req, tmpl) 183 content = getattr(webcommands, cmd)(self, req, tmpl)
184 req.respond(HTTP_OK, ctype) 184 req.respond(HTTP_OK, ctype)
185 185
186 return content 186 return content
187 187
188 except revlog.LookupError, err: 188 except error.LookupError, err:
189 req.respond(HTTP_NOT_FOUND, ctype) 189 req.respond(HTTP_NOT_FOUND, ctype)
190 msg = str(err) 190 msg = str(err)
191 if 'manifest' not in msg: 191 if 'manifest' not in msg:
192 msg = 'revision not found: %s' % err.name 192 msg = 'revision not found: %s' % err.name
193 return tmpl('error', error=msg) 193 return tmpl('error', error=msg)
194 except (RepoError, revlog.RevlogError), inst: 194 except (RepoError, error.RevlogError), inst:
195 req.respond(HTTP_SERVER_ERROR, ctype) 195 req.respond(HTTP_SERVER_ERROR, ctype)
196 return tmpl('error', error=str(inst)) 196 return tmpl('error', error=str(inst))
197 except ErrorResponse, inst: 197 except ErrorResponse, inst:
198 req.respond(inst.code, ctype) 198 req.respond(inst.code, ctype)
199 return tmpl('error', error=inst.message) 199 return tmpl('error', error=inst.message)