Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 4164:5c1e18bb804c
hgweb: use the given revision in the name of the archive
If you ask for an archive in hgweb by tagname the directory in the archive
should include the tagname not the changeset-id.
author | Michael Gebetsroither <michael.geb@gmx.at> |
---|---|
date | Thu, 08 Mar 2007 22:36:12 +0100 |
parents | 49237d6ae97d |
children | 0d51eb296fb9 |
comparison
equal
deleted
inserted
replaced
4162:b2d9e553cdc8 | 4164:5c1e18bb804c |
---|---|
604 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), | 604 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
605 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), | 605 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), |
606 'zip': ('application/zip', 'zip', '.zip', None), | 606 'zip': ('application/zip', 'zip', '.zip', None), |
607 } | 607 } |
608 | 608 |
609 def archive(self, req, cnode, type_): | 609 def archive(self, req, id, type_): |
610 reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) | 610 reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) |
611 name = "%s-%s" % (reponame, short(cnode)) | 611 cnode = self.repo.lookup(id) |
612 arch_version = id | |
613 if cnode == id: | |
614 arch_version = short(cnode) | |
615 name = "%s-%s" % (reponame, arch_version) | |
612 mimetype, artype, extension, encoding = self.archive_specs[type_] | 616 mimetype, artype, extension, encoding = self.archive_specs[type_] |
613 headers = [('Content-type', mimetype), | 617 headers = [('Content-type', mimetype), |
614 ('Content-disposition', 'attachment; filename=%s%s' % | 618 ('Content-disposition', 'attachment; filename=%s%s' % |
615 (name, extension))] | 619 (name, extension))] |
616 if encoding: | 620 if encoding: |
987 req.write(z.compress(chunk)) | 991 req.write(z.compress(chunk)) |
988 | 992 |
989 req.write(z.flush()) | 993 req.write(z.flush()) |
990 | 994 |
991 def do_archive(self, req): | 995 def do_archive(self, req): |
992 changeset = self.repo.lookup(req.form['node'][0]) | |
993 type_ = req.form['type'][0] | 996 type_ = req.form['type'][0] |
994 allowed = self.configlist("web", "allow_archive") | 997 allowed = self.configlist("web", "allow_archive") |
995 if (type_ in self.archives and (type_ in allowed or | 998 if (type_ in self.archives and (type_ in allowed or |
996 self.configbool("web", "allow" + type_, False))): | 999 self.configbool("web", "allow" + type_, False))): |
997 self.archive(req, changeset, type_) | 1000 self.archive(req, req.form['node'][0], type_) |
998 return | 1001 return |
999 | 1002 |
1000 req.write(self.t("error")) | 1003 req.write(self.t("error")) |
1001 | 1004 |
1002 def do_static(self, req): | 1005 def do_static(self, req): |