6 # This software may be used and distributed according to the terms |
6 # This software may be used and distributed according to the terms |
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 |
|
12 from mercurial import ui, hg, util, hook, error |
11 from mercurial import ui, hg, util, hook, error |
13 from mercurial import templater, templatefilters |
12 from mercurial import templater, templatefilters |
14 from common import get_mtime, style_map, ErrorResponse |
13 from common import get_mtime, style_map, ErrorResponse |
15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
14 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
16 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED |
15 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED |
189 req.respond(HTTP_NOT_FOUND, ctype) |
188 req.respond(HTTP_NOT_FOUND, ctype) |
190 msg = str(err) |
189 msg = str(err) |
191 if 'manifest' not in msg: |
190 if 'manifest' not in msg: |
192 msg = 'revision not found: %s' % err.name |
191 msg = 'revision not found: %s' % err.name |
193 return tmpl('error', error=msg) |
192 return tmpl('error', error=msg) |
194 except (RepoError, error.RevlogError), inst: |
193 except (error.RepoError, error.RevlogError), inst: |
195 req.respond(HTTP_SERVER_ERROR, ctype) |
194 req.respond(HTTP_SERVER_ERROR, ctype) |
196 return tmpl('error', error=str(inst)) |
195 return tmpl('error', error=str(inst)) |
197 except ErrorResponse, inst: |
196 except ErrorResponse, inst: |
198 req.respond(inst.code, ctype) |
197 req.respond(inst.code, ctype) |
199 return tmpl('error', error=inst.message) |
198 return tmpl('error', error=inst.message) |