10 from mercurial import revlog, archival, templatefilters |
10 from mercurial import revlog, 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_NOT_FOUND |
15 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND |
16 from mercurial import graphmod, util |
16 from mercurial import graphmod, util |
17 |
17 |
18 # __all__ is populated with the allowed commands. Be sure to add to it if |
18 # __all__ is populated with the allowed commands. Be sure to add to it if |
19 # you're adding a new command, or the new command won't work. |
19 # you're adding a new command, or the new command won't work. |
20 |
20 |
533 def archive(web, req, tmpl): |
533 def archive(web, req, tmpl): |
534 type_ = req.form.get('type', [None])[0] |
534 type_ = req.form.get('type', [None])[0] |
535 allowed = web.configlist("web", "allow_archive") |
535 allowed = web.configlist("web", "allow_archive") |
536 key = req.form['node'][0] |
536 key = req.form['node'][0] |
537 |
537 |
538 if not (type_ in web.archives and (type_ in allowed or |
538 if type_ not in web.archives: |
539 web.configbool("web", "allow" + type_, False))): |
|
540 msg = 'Unsupported archive type: %s' % type_ |
539 msg = 'Unsupported archive type: %s' % type_ |
541 raise ErrorResponse(HTTP_NOT_FOUND, msg) |
540 raise ErrorResponse(HTTP_NOT_FOUND, msg) |
|
541 |
|
542 if not ((type_ in allowed or |
|
543 web.configbool("web", "allow" + type_, False))): |
|
544 msg = 'Archive type not allowed: %s' % type_ |
|
545 raise ErrorResponse(HTTP_FORBIDDEN, msg) |
542 |
546 |
543 reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame)) |
547 reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame)) |
544 cnode = web.repo.lookup(key) |
548 cnode = web.repo.lookup(key) |
545 arch_version = key |
549 arch_version = key |
546 if cnode == key or key == 'tip': |
550 if cnode == key or key == 'tip': |