comparison mercurial/hgweb/webcommands.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 4dd7b28003d2
children 1d54e2f6c0b7
comparison
equal deleted inserted replaced
7632:9626819b2e3d 7633:08cabecfa8a8
5 # This software may be used and distributed according to the terms 5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import os, mimetypes, re, cgi, copy 8 import os, mimetypes, re, cgi, copy
9 import webutil 9 import webutil
10 from mercurial import revlog, archival, templatefilters 10 from mercurial import error, archival, templatefilters
11 from mercurial.node import short, hex, nullid 11 from mercurial.node import short, hex, nullid
12 from mercurial.util import binary, datestr 12 from mercurial.util import binary, datestr
13 from mercurial.repo import RepoError 13 from mercurial.repo import RepoError
14 from common import paritygen, staticfile, get_contact, ErrorResponse 14 from common import paritygen, staticfile, get_contact, ErrorResponse
15 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND 15 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND
37 req.respond(HTTP_OK, web.ctype) 37 req.respond(HTTP_OK, web.ctype)
38 return content 38 return content
39 39
40 try: 40 try:
41 fctx = webutil.filectx(web.repo, req) 41 fctx = webutil.filectx(web.repo, req)
42 except revlog.LookupError, inst: 42 except error.LookupError, inst:
43 try: 43 try:
44 content = manifest(web, req, tmpl) 44 content = manifest(web, req, tmpl)
45 req.respond(HTTP_OK, web.ctype) 45 req.respond(HTTP_OK, web.ctype)
46 return content 46 return content
47 except ErrorResponse: 47 except ErrorResponse:
91 path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) 91 path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0])
92 if not path: 92 if not path:
93 return manifest(web, req, tmpl) 93 return manifest(web, req, tmpl)
94 try: 94 try:
95 return _filerevision(web, tmpl, webutil.filectx(web.repo, req)) 95 return _filerevision(web, tmpl, webutil.filectx(web.repo, req))
96 except revlog.LookupError, inst: 96 except error.LookupError, inst:
97 try: 97 try:
98 return manifest(web, req, tmpl) 98 return manifest(web, req, tmpl)
99 except ErrorResponse: 99 except ErrorResponse:
100 raise inst 100 raise inst
101 101
519 519
520 try: 520 try:
521 fctx = webutil.filectx(web.repo, req) 521 fctx = webutil.filectx(web.repo, req)
522 f = fctx.path() 522 f = fctx.path()
523 fl = fctx.filelog() 523 fl = fctx.filelog()
524 except revlog.LookupError: 524 except error.LookupError:
525 f = webutil.cleanpath(web.repo, req.form['file'][0]) 525 f = webutil.cleanpath(web.repo, req.form['file'][0])
526 fl = web.repo.file(f) 526 fl = web.repo.file(f)
527 numrevs = len(fl) 527 numrevs = len(fl)
528 if not numrevs: # file doesn't exist at all 528 if not numrevs: # file doesn't exist at all
529 raise 529 raise