Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 6217:fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
author | Joel Rosdahl <joel@rosdahl.net> |
---|---|
date | Thu, 06 Mar 2008 22:51:16 +0100 |
parents | f89fd07fc51d |
children | cf1fa60fdaf4 |
comparison
equal
deleted
inserted
replaced
6216:a88259018f79 | 6217:fe8dbbe9520d |
---|---|
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, re | 9 import os, mimetypes, re |
10 from mercurial.node import hex, nullid, short | 10 from mercurial.node import hex, nullid, short |
11 from mercurial.repo import RepoError | |
11 from mercurial import mdiff, ui, hg, util, archival, patch, hook | 12 from mercurial import mdiff, ui, hg, util, archival, patch, hook |
12 from mercurial import revlog, templater, templatefilters, changegroup | 13 from mercurial import revlog, templater, templatefilters, changegroup |
13 from common import get_mtime, style_map, paritygen, countgen, get_contact | 14 from common import get_mtime, style_map, paritygen, countgen, get_contact |
14 from common import ErrorResponse | 15 from common import ErrorResponse |
15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | 16 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
72 | 73 |
73 for label, node in l: | 74 for label, node in l: |
74 yield {"label": label, "node": node} | 75 yield {"label": label, "node": node} |
75 | 76 |
76 yield {"label": "tip", "node": "tip"} | 77 yield {"label": "tip", "node": "tip"} |
77 except hg.RepoError: | 78 except RepoError: |
78 pass | 79 pass |
79 | 80 |
80 return nav | 81 return nav |
81 | 82 |
82 class hgweb(object): | 83 class hgweb(object): |
246 del tmpl | 247 del tmpl |
247 | 248 |
248 except revlog.LookupError, err: | 249 except revlog.LookupError, err: |
249 req.respond(HTTP_NOT_FOUND, ctype) | 250 req.respond(HTTP_NOT_FOUND, ctype) |
250 req.write(tmpl('error', error='revision not found: %s' % err.name)) | 251 req.write(tmpl('error', error='revision not found: %s' % err.name)) |
251 except (hg.RepoError, revlog.RevlogError), inst: | 252 except (RepoError, revlog.RevlogError), inst: |
252 req.respond(HTTP_SERVER_ERROR, ctype) | 253 req.respond(HTTP_SERVER_ERROR, ctype) |
253 req.write(tmpl('error', error=str(inst))) | 254 req.write(tmpl('error', error=str(inst))) |
254 except ErrorResponse, inst: | 255 except ErrorResponse, inst: |
255 req.respond(inst.code, ctype) | 256 req.respond(inst.code, ctype) |
256 req.write(tmpl('error', error=inst.message)) | 257 req.write(tmpl('error', error=inst.message)) |
913 else: | 914 else: |
914 changeid = self.repo.changelog.count() - 1 | 915 changeid = self.repo.changelog.count() - 1 |
915 | 916 |
916 try: | 917 try: |
917 ctx = self.repo.changectx(changeid) | 918 ctx = self.repo.changectx(changeid) |
918 except hg.RepoError: | 919 except RepoError: |
919 man = self.repo.manifest | 920 man = self.repo.manifest |
920 mn = man.lookup(changeid) | 921 mn = man.lookup(changeid) |
921 ctx = self.repo.changectx(man.linkrev(mn)) | 922 ctx = self.repo.changectx(man.linkrev(mn)) |
922 | 923 |
923 return ctx | 924 return ctx |
929 else: | 930 else: |
930 changeid = req.form['filenode'][0] | 931 changeid = req.form['filenode'][0] |
931 try: | 932 try: |
932 ctx = self.repo.changectx(changeid) | 933 ctx = self.repo.changectx(changeid) |
933 fctx = ctx.filectx(path) | 934 fctx = ctx.filectx(path) |
934 except hg.RepoError: | 935 except RepoError: |
935 fctx = self.repo.filectx(path, fileid=changeid) | 936 fctx = self.repo.filectx(path, fileid=changeid) |
936 | 937 |
937 return fctx | 938 return fctx |
938 | 939 |
939 def check_perm(self, req, op, default): | 940 def check_perm(self, req, op, default): |