Show More
@@ -37,6 +37,8 class hgweb(object): | |||||
37 | self.mtime = -1 |
|
37 | self.mtime = -1 | |
38 | self.reponame = name |
|
38 | self.reponame = name | |
39 | self.archives = 'zip', 'gz', 'bz2' |
|
39 | self.archives = 'zip', 'gz', 'bz2' | |
|
40 | self.templatepath = self.repo.ui.config("web", "templates", | |||
|
41 | templater.templatepath()) | |||
40 |
|
42 | |||
41 | def refresh(self): |
|
43 | def refresh(self): | |
42 | mtime = get_mtime(self.repo.root) |
|
44 | mtime = get_mtime(self.repo.root) | |
@@ -644,13 +646,13 class hgweb(object): | |||||
644 | # tags -> list of changesets corresponding to tags |
|
646 | # tags -> list of changesets corresponding to tags | |
645 | # find tag, changeset, file |
|
647 | # find tag, changeset, file | |
646 |
|
648 | |||
647 | def run(self, req=hgrequest()): |
|
649 | def cleanpath(self, path): | |
648 | def clean(path): |
|
|||
649 |
|
|
650 | p = util.normpath(path) | |
650 |
|
|
651 | if p[:2] == "..": | |
651 |
|
|
652 | raise Exception("suspicious path") | |
652 |
|
|
653 | return p | |
653 |
|
654 | |||
|
655 | def run(self, req=hgrequest()): | |||
654 | def header(**map): |
|
656 | def header(**map): | |
655 | yield self.t("header", **map) |
|
657 | yield self.t("header", **map) | |
656 |
|
658 | |||
@@ -686,15 +688,13 class hgweb(object): | |||||
686 |
|
688 | |||
687 | expand_form(req.form) |
|
689 | expand_form(req.form) | |
688 |
|
690 | |||
689 | t = self.repo.ui.config("web", "templates", templater.templatepath()) |
|
691 | m = os.path.join(self.templatepath, "map") | |
690 | static = self.repo.ui.config("web", "static", os.path.join(t,"static")) |
|
|||
691 | m = os.path.join(t, "map") |
|
|||
692 | style = self.repo.ui.config("web", "style", "") |
|
692 | style = self.repo.ui.config("web", "style", "") | |
693 | if req.form.has_key('style'): |
|
693 | if req.form.has_key('style'): | |
694 | style = req.form['style'][0] |
|
694 | style = req.form['style'][0] | |
695 | if style: |
|
695 | if style: | |
696 | b = os.path.basename("map-" + style) |
|
696 | b = os.path.basename("map-" + style) | |
697 | p = os.path.join(t, b) |
|
697 | p = os.path.join(self.templatepath, b) | |
698 | if os.path.isfile(p): |
|
698 | if os.path.isfile(p): | |
699 | m = p |
|
699 | m = p | |
700 |
|
700 | |||
@@ -719,7 +719,15 class hgweb(object): | |||||
719 | req.form['cmd'] = [self.t.cache['default'],] |
|
719 | req.form['cmd'] = [self.t.cache['default'],] | |
720 |
|
720 | |||
721 | cmd = req.form['cmd'][0] |
|
721 | cmd = req.form['cmd'][0] | |
722 | if cmd == 'changelog': |
|
722 | ||
|
723 | method = getattr(self, 'do_' + cmd, None) | |||
|
724 | if method: | |||
|
725 | method(req) | |||
|
726 | else: | |||
|
727 | req.write(self.t("error")) | |||
|
728 | req.done() | |||
|
729 | ||||
|
730 | def do_changelog(self, req): | |||
723 |
|
|
731 | hi = self.repo.changelog.count() - 1 | |
724 |
|
|
732 | if req.form.has_key('rev'): | |
725 |
|
|
733 | hi = req.form['rev'][0] | |
@@ -731,41 +739,41 class hgweb(object): | |||||
731 |
|
739 | |||
732 |
|
|
740 | req.write(self.changelog(hi)) | |
733 |
|
741 | |||
734 | elif cmd == 'changeset': |
|
742 | def do_changeset(self, req): | |
735 |
|
|
743 | req.write(self.changeset(req.form['node'][0])) | |
736 |
|
744 | |||
737 | elif cmd == 'manifest': |
|
745 | def do_manifest(self, req): | |
738 |
|
|
746 | req.write(self.manifest(req.form['manifest'][0], | |
739 |
|
|
747 | self.cleanpath(req.form['path'][0]))) | |
740 |
|
748 | |||
741 | elif cmd == 'tags': |
|
749 | def do_tags(self, req): | |
742 |
|
|
750 | req.write(self.tags()) | |
743 |
|
751 | |||
744 | elif cmd == 'summary': |
|
752 | def do_summary(self, req): | |
745 |
|
|
753 | req.write(self.summary()) | |
746 |
|
754 | |||
747 | elif cmd == 'filediff': |
|
755 | def do_filediff(self, req): | |
748 |
|
|
756 | req.write(self.filediff(self.cleanpath(req.form['file'][0]), | |
749 |
|
|
757 | req.form['node'][0])) | |
750 |
|
758 | |||
751 | elif cmd == 'file': |
|
759 | def do_file(self, req): | |
752 |
|
|
760 | req.write(self.filerevision(self.cleanpath(req.form['file'][0]), | |
753 |
|
|
761 | req.form['filenode'][0])) | |
754 |
|
762 | |||
755 | elif cmd == 'annotate': |
|
763 | def do_annotate(self, req): | |
756 |
|
|
764 | req.write(self.fileannotate(self.cleanpath(req.form['file'][0]), | |
757 |
|
|
765 | req.form['filenode'][0])) | |
758 |
|
766 | |||
759 | elif cmd == 'filelog': |
|
767 | def do_filelog(self, req): | |
760 |
|
|
768 | req.write(self.filelog(self.cleanpath(req.form['file'][0]), | |
761 |
|
|
769 | req.form['filenode'][0])) | |
762 |
|
770 | |||
763 | elif cmd == 'heads': |
|
771 | def do_heads(self, req): | |
764 |
|
|
772 | resp = " ".join(map(hex, self.repo.heads())) + "\n" | |
765 |
|
|
773 | req.httphdr("application/mercurial-0.1", length=len(resp)) | |
766 |
|
|
774 | req.write(resp) | |
767 |
|
775 | |||
768 | elif cmd == 'branches': |
|
776 | def do_branches(self, req): | |
769 |
|
|
777 | nodes = [] | |
770 |
|
|
778 | if req.form.has_key('nodes'): | |
771 |
|
|
779 | nodes = map(bin, req.form['nodes'][0].split(" ")) | |
@@ -776,7 +784,7 class hgweb(object): | |||||
776 |
|
|
784 | req.httphdr("application/mercurial-0.1", length=len(resp)) | |
777 |
|
|
785 | req.write(resp) | |
778 |
|
786 | |||
779 | elif cmd == 'between': |
|
787 | def do_between(self, req): | |
780 |
|
|
788 | nodes = [] | |
781 |
|
|
789 | if req.form.has_key('pairs'): | |
782 |
|
|
790 | pairs = [map(bin, p.split("-")) | |
@@ -788,7 +796,7 class hgweb(object): | |||||
788 |
|
|
796 | req.httphdr("application/mercurial-0.1", length=len(resp)) | |
789 |
|
|
797 | req.write(resp) | |
790 |
|
798 | |||
791 | elif cmd == 'changegroup': |
|
799 | def do_changegroup(self, req): | |
792 |
|
|
800 | req.httphdr("application/mercurial-0.1") | |
793 |
|
|
801 | nodes = [] | |
794 |
|
|
802 | if not self.allowpull: | |
@@ -807,7 +815,7 class hgweb(object): | |||||
807 |
|
815 | |||
808 |
|
|
816 | req.write(z.flush()) | |
809 |
|
817 | |||
810 | elif cmd == 'archive': |
|
818 | def do_archive(self, req): | |
811 |
|
|
819 | changeset = self.repo.lookup(req.form['node'][0]) | |
812 |
|
|
820 | type_ = req.form['type'][0] | |
813 |
|
|
821 | allowed = self.repo.ui.config("web", "allow_archive", "").split() | |
@@ -818,11 +826,10 class hgweb(object): | |||||
818 |
|
826 | |||
819 |
|
|
827 | req.write(self.t("error")) | |
820 |
|
828 | |||
821 | elif cmd == 'static': |
|
829 | def do_static(self, req): | |
822 |
|
|
830 | fname = req.form['file'][0] | |
|
831 | static = self.repo.ui.config("web", "static", | |||
|
832 | os.path.join(self.templatepath, | |||
|
833 | "static")) | |||
823 |
|
|
834 | req.write(staticfile(static, fname) | |
824 |
|
|
835 | or self.t("error", error="%r not found" % fname)) | |
825 |
|
||||
826 | else: |
|
|||
827 | req.write(self.t("error")) |
|
|||
828 | req.done() |
|
General Comments 0
You need to be logged in to leave comments.
Login now