Mercurial > hg
comparison mercurial/hgweb/webutil.py @ 17289:f2d6b4f8e78c stable
hgweb: avoid traceback when file or node parameters are missing
Previously, browsing to http://serv/diff would generate an internal
server error due to the file and node parameters being missing.
The same error also occurred for filelog, comparison and annotate.
author | Ross Lagerwall <rosslagerwall@gmail.com> |
---|---|
date | Mon, 30 Jul 2012 11:02:10 +0200 |
parents | 1ae119269ddc |
children | 5c64ce6168da |
comparison
equal
deleted
inserted
replaced
17288:fa223eecc6d7 | 17289:f2d6b4f8e78c |
---|---|
8 | 8 |
9 import os, mimetypes, copy | 9 import os, mimetypes, copy |
10 from mercurial import match, patch, scmutil, error, ui, util | 10 from mercurial import match, patch, scmutil, error, ui, util |
11 from mercurial.i18n import _ | 11 from mercurial.i18n import _ |
12 from mercurial.node import hex, nullid | 12 from mercurial.node import hex, nullid |
13 from common import ErrorResponse | |
14 from common import HTTP_NOT_FOUND | |
13 import difflib | 15 import difflib |
14 | 16 |
15 def up(p): | 17 def up(p): |
16 if p[0] != "/": | 18 if p[0] != "/": |
17 p = "/" + p | 19 p = "/" + p |
152 ctx = repo[man.linkrev(man.rev(man.lookup(changeid)))] | 154 ctx = repo[man.linkrev(man.rev(man.lookup(changeid)))] |
153 | 155 |
154 return ctx | 156 return ctx |
155 | 157 |
156 def filectx(repo, req): | 158 def filectx(repo, req): |
159 if 'file' not in req.form: | |
160 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given') | |
157 path = cleanpath(repo, req.form['file'][0]) | 161 path = cleanpath(repo, req.form['file'][0]) |
158 if 'node' in req.form: | 162 if 'node' in req.form: |
159 changeid = req.form['node'][0] | 163 changeid = req.form['node'][0] |
164 elif 'filenode' in req.form: | |
165 changeid = req.form['filenode'][0] | |
160 else: | 166 else: |
161 changeid = req.form['filenode'][0] | 167 raise ErrorResponse(HTTP_NOT_FOUND, 'node or filenode not given') |
162 try: | 168 try: |
163 fctx = repo[changeid][path] | 169 fctx = repo[changeid][path] |
164 except error.RepoError: | 170 except error.RepoError: |
165 fctx = repo.filectx(path, fileid=changeid) | 171 fctx = repo.filectx(path, fileid=changeid) |
166 | 172 |