Mercurial > hg
comparison mercurial/hgweb.py @ 2119:f62195054c5b
Cleaned hgweb.py a little bit
author | Alexander Schremmer <alex AT alexanderweb DOT de> |
---|---|
date | Sun, 23 Apr 2006 00:15:30 +0200 |
parents | 633d733e7b11 |
children | 150cdd6c3c90 |
comparison
equal
deleted
inserted
replaced
2116:366e6328d10e | 2119:f62195054c5b |
---|---|
774 }) | 774 }) |
775 | 775 |
776 if not req.form.has_key('cmd'): | 776 if not req.form.has_key('cmd'): |
777 req.form['cmd'] = [self.t.cache['default'],] | 777 req.form['cmd'] = [self.t.cache['default'],] |
778 | 778 |
779 if req.form['cmd'][0] == 'changelog': | 779 cmd = req.form['cmd'][0] |
780 c = self.repo.changelog.count() - 1 | 780 if cmd == 'changelog': |
781 hi = c | 781 hi = self.repo.changelog.count() - 1 |
782 if req.form.has_key('rev'): | 782 if req.form.has_key('rev'): |
783 hi = req.form['rev'][0] | 783 hi = req.form['rev'][0] |
784 try: | 784 try: |
785 hi = self.repo.changelog.rev(self.repo.lookup(hi)) | 785 hi = self.repo.changelog.rev(self.repo.lookup(hi)) |
786 except hg.RepoError: | 786 except hg.RepoError: |
787 req.write(self.search(hi)) | 787 req.write(self.search(hi)) # XXX redirect to 404 page? |
788 return | 788 return |
789 | 789 |
790 req.write(self.changelog(hi)) | 790 req.write(self.changelog(hi)) |
791 | 791 |
792 elif req.form['cmd'][0] == 'changeset': | 792 elif cmd == 'changeset': |
793 req.write(self.changeset(req.form['node'][0])) | 793 req.write(self.changeset(req.form['node'][0])) |
794 | 794 |
795 elif req.form['cmd'][0] == 'manifest': | 795 elif cmd == 'manifest': |
796 req.write(self.manifest(req.form['manifest'][0], | 796 req.write(self.manifest(req.form['manifest'][0], |
797 clean(req.form['path'][0]))) | 797 clean(req.form['path'][0]))) |
798 | 798 |
799 elif req.form['cmd'][0] == 'tags': | 799 elif cmd == 'tags': |
800 req.write(self.tags()) | 800 req.write(self.tags()) |
801 | 801 |
802 elif req.form['cmd'][0] == 'summary': | 802 elif cmd == 'summary': |
803 req.write(self.summary()) | 803 req.write(self.summary()) |
804 | 804 |
805 elif req.form['cmd'][0] == 'filediff': | 805 elif cmd == 'filediff': |
806 req.write(self.filediff(clean(req.form['file'][0]), | 806 req.write(self.filediff(clean(req.form['file'][0]), |
807 req.form['node'][0])) | 807 req.form['node'][0])) |
808 | 808 |
809 elif req.form['cmd'][0] == 'file': | 809 elif cmd == 'file': |
810 req.write(self.filerevision(clean(req.form['file'][0]), | 810 req.write(self.filerevision(clean(req.form['file'][0]), |
811 req.form['filenode'][0])) | 811 req.form['filenode'][0])) |
812 | 812 |
813 elif req.form['cmd'][0] == 'annotate': | 813 elif cmd == 'annotate': |
814 req.write(self.fileannotate(clean(req.form['file'][0]), | 814 req.write(self.fileannotate(clean(req.form['file'][0]), |
815 req.form['filenode'][0])) | 815 req.form['filenode'][0])) |
816 | 816 |
817 elif req.form['cmd'][0] == 'filelog': | 817 elif cmd == 'filelog': |
818 req.write(self.filelog(clean(req.form['file'][0]), | 818 req.write(self.filelog(clean(req.form['file'][0]), |
819 req.form['filenode'][0])) | 819 req.form['filenode'][0])) |
820 | 820 |
821 elif req.form['cmd'][0] == 'heads': | 821 elif cmd == 'heads': |
822 req.httphdr("application/mercurial-0.1") | 822 req.httphdr("application/mercurial-0.1") |
823 h = self.repo.heads() | 823 h = self.repo.heads() |
824 req.write(" ".join(map(hex, h)) + "\n") | 824 req.write(" ".join(map(hex, h)) + "\n") |
825 | 825 |
826 elif req.form['cmd'][0] == 'branches': | 826 elif cmd == 'branches': |
827 req.httphdr("application/mercurial-0.1") | 827 req.httphdr("application/mercurial-0.1") |
828 nodes = [] | 828 nodes = [] |
829 if req.form.has_key('nodes'): | 829 if req.form.has_key('nodes'): |
830 nodes = map(bin, req.form['nodes'][0].split(" ")) | 830 nodes = map(bin, req.form['nodes'][0].split(" ")) |
831 for b in self.repo.branches(nodes): | 831 for b in self.repo.branches(nodes): |
832 req.write(" ".join(map(hex, b)) + "\n") | 832 req.write(" ".join(map(hex, b)) + "\n") |
833 | 833 |
834 elif req.form['cmd'][0] == 'between': | 834 elif cmd == 'between': |
835 req.httphdr("application/mercurial-0.1") | 835 req.httphdr("application/mercurial-0.1") |
836 nodes = [] | 836 nodes = [] |
837 if req.form.has_key('pairs'): | 837 if req.form.has_key('pairs'): |
838 pairs = [map(bin, p.split("-")) | 838 pairs = [map(bin, p.split("-")) |
839 for p in req.form['pairs'][0].split(" ")] | 839 for p in req.form['pairs'][0].split(" ")] |
840 for b in self.repo.between(pairs): | 840 for b in self.repo.between(pairs): |
841 req.write(" ".join(map(hex, b)) + "\n") | 841 req.write(" ".join(map(hex, b)) + "\n") |
842 | 842 |
843 elif req.form['cmd'][0] == 'changegroup': | 843 elif cmd == 'changegroup': |
844 req.httphdr("application/mercurial-0.1") | 844 req.httphdr("application/mercurial-0.1") |
845 nodes = [] | 845 nodes = [] |
846 if not self.allowpull: | 846 if not self.allowpull: |
847 return | 847 return |
848 | 848 |
857 break | 857 break |
858 req.write(z.compress(chunk)) | 858 req.write(z.compress(chunk)) |
859 | 859 |
860 req.write(z.flush()) | 860 req.write(z.flush()) |
861 | 861 |
862 elif req.form['cmd'][0] == 'archive': | 862 elif cmd == 'archive': |
863 changeset = self.repo.lookup(req.form['node'][0]) | 863 changeset = self.repo.lookup(req.form['node'][0]) |
864 type = req.form['type'][0] | 864 type = req.form['type'][0] |
865 if (type in self.archives and | 865 if (type in self.archives and |
866 self.repo.ui.configbool("web", "allow" + type, False)): | 866 self.repo.ui.configbool("web", "allow" + type, False)): |
867 self.archive(req, changeset, type) | 867 self.archive(req, changeset, type) |
868 return | 868 return |
869 | 869 |
870 req.write(self.t("error")) | 870 req.write(self.t("error")) |
871 | 871 |
872 elif req.form['cmd'][0] == 'static': | 872 elif cmd == 'static': |
873 fname = req.form['file'][0] | 873 fname = req.form['file'][0] |
874 req.write(staticfile(static, fname) | 874 req.write(staticfile(static, fname) |
875 or self.t("error", error="%r not found" % fname)) | 875 or self.t("error", error="%r not found" % fname)) |
876 | 876 |
877 else: | 877 else: |