Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 2394:a8f1049d1d2d
hgweb: fix errors and warnings found by pychecker
- fix missing import
- use type_ instead of type
- remove unused variable
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 04 Jun 2006 12:19:51 +0200 |
parents | d351a3be3371 |
children | a2df85adface |
comparison
equal
deleted
inserted
replaced
2393:5083cba2a777 | 2394:a8f1049d1d2d |
---|---|
589 cl = self.repo.changelog | 589 cl = self.repo.changelog |
590 mf = cl.read(cl.tip())[0] | 590 mf = cl.read(cl.tip())[0] |
591 count = cl.count() | 591 count = cl.count() |
592 start = max(0, count - self.maxchanges) | 592 start = max(0, count - self.maxchanges) |
593 end = min(count, start + self.maxchanges) | 593 end = min(count, start + self.maxchanges) |
594 pos = end - 1 | |
595 | 594 |
596 yield self.t("summary", | 595 yield self.t("summary", |
597 desc = self.repo.ui.config("web", "description", "unknown"), | 596 desc = self.repo.ui.config("web", "description", "unknown"), |
598 owner = (self.repo.ui.config("ui", "username") or # preferred | 597 owner = (self.repo.ui.config("ui", "username") or # preferred |
599 self.repo.ui.config("web", "contact") or # deprecated | 598 self.repo.ui.config("web", "contact") or # deprecated |
627 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), | 626 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
628 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), | 627 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), |
629 'zip': ('application/zip', 'zip', '.zip', None), | 628 'zip': ('application/zip', 'zip', '.zip', None), |
630 } | 629 } |
631 | 630 |
632 def archive(self, req, cnode, type): | 631 def archive(self, req, cnode, type_): |
633 reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) | 632 reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) |
634 name = "%s-%s" % (reponame, short(cnode)) | 633 name = "%s-%s" % (reponame, short(cnode)) |
635 mimetype, artype, extension, encoding = self.archive_specs[type] | 634 mimetype, artype, extension, encoding = self.archive_specs[type_] |
636 headers = [('Content-type', mimetype), | 635 headers = [('Content-type', mimetype), |
637 ('Content-disposition', 'attachment; filename=%s%s' % | 636 ('Content-disposition', 'attachment; filename=%s%s' % |
638 (name, extension))] | 637 (name, extension))] |
639 if encoding: | 638 if encoding: |
640 headers.append(('Content-encoding', encoding)) | 639 headers.append(('Content-encoding', encoding)) |
647 | 646 |
648 def run(self, req=hgrequest()): | 647 def run(self, req=hgrequest()): |
649 def clean(path): | 648 def clean(path): |
650 p = util.normpath(path) | 649 p = util.normpath(path) |
651 if p[:2] == "..": | 650 if p[:2] == "..": |
652 raise "suspicious path" | 651 raise Exception("suspicious path") |
653 return p | 652 return p |
654 | 653 |
655 def header(**map): | 654 def header(**map): |
656 yield self.t("header", **map) | 655 yield self.t("header", **map) |
657 | 656 |
802 | 801 |
803 req.write(z.flush()) | 802 req.write(z.flush()) |
804 | 803 |
805 elif cmd == 'archive': | 804 elif cmd == 'archive': |
806 changeset = self.repo.lookup(req.form['node'][0]) | 805 changeset = self.repo.lookup(req.form['node'][0]) |
807 type = req.form['type'][0] | 806 type_ = req.form['type'][0] |
808 allowed = self.repo.ui.config("web", "allow_archive", "").split() | 807 allowed = self.repo.ui.config("web", "allow_archive", "").split() |
809 if (type in self.archives and (type in allowed or | 808 if (type_ in self.archives and (type_ in allowed or |
810 self.repo.ui.configbool("web", "allow" + type, False))): | 809 self.repo.ui.configbool("web", "allow" + type_, False))): |
811 self.archive(req, changeset, type) | 810 self.archive(req, changeset, type_) |
812 return | 811 return |
813 | 812 |
814 req.write(self.t("error")) | 813 req.write(self.t("error")) |
815 | 814 |
816 elif cmd == 'static': | 815 elif cmd == 'static': |