Mercurial > hg
comparison mercurial/hgweb.py @ 2127:8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 25 Apr 2006 19:38:19 +0200 |
parents | 27fd8b7a6c51 |
children | c72e618c1204 |
comparison
equal
deleted
inserted
replaced
2126:2e77f7852e82 | 2127:8a85dbbadddf |
---|---|
887 or self.t("error", error="%r not found" % fname)) | 887 or self.t("error", error="%r not found" % fname)) |
888 | 888 |
889 else: | 889 else: |
890 req.write(self.t("error")) | 890 req.write(self.t("error")) |
891 | 891 |
892 def create_server(repo): | 892 def create_server(ui, repo): |
893 use_threads = True | 893 use_threads = True |
894 | 894 |
895 def openlog(opt, default): | 895 def openlog(opt, default): |
896 if opt and opt != '-': | 896 if opt and opt != '-': |
897 return open(opt, 'w') | 897 return open(opt, 'w') |
898 return default | 898 return default |
899 | 899 |
900 address = repo.ui.config("web", "address", "") | 900 address = ui.config("web", "address", "") |
901 port = int(repo.ui.config("web", "port", 8000)) | 901 port = int(ui.config("web", "port", 8000)) |
902 use_ipv6 = repo.ui.configbool("web", "ipv6") | 902 use_ipv6 = ui.configbool("web", "ipv6") |
903 webdir_conf = repo.ui.config("web", "webdir_conf") | 903 webdir_conf = ui.config("web", "webdir_conf") |
904 accesslog = openlog(repo.ui.config("web", "accesslog", "-"), sys.stdout) | 904 accesslog = openlog(ui.config("web", "accesslog", "-"), sys.stdout) |
905 errorlog = openlog(repo.ui.config("web", "errorlog", "-"), sys.stderr) | 905 errorlog = openlog(ui.config("web", "errorlog", "-"), sys.stderr) |
906 | 906 |
907 if use_threads: | 907 if use_threads: |
908 try: | 908 try: |
909 from threading import activeCount | 909 from threading import activeCount |
910 except ImportError: | 910 except ImportError: |
986 req = hgrequest(self.rfile, self.wfile, env) | 986 req = hgrequest(self.rfile, self.wfile, env) |
987 self.send_response(200, "Script output follows") | 987 self.send_response(200, "Script output follows") |
988 | 988 |
989 if webdir_conf: | 989 if webdir_conf: |
990 hgwebobj = hgwebdir(webdir_conf) | 990 hgwebobj = hgwebdir(webdir_conf) |
991 elif repo is not None: | |
992 hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot)) | |
991 else: | 993 else: |
992 hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot)) | 994 raise hg.RepoError(_('no repo found')) |
993 hgwebobj.run(req) | 995 hgwebobj.run(req) |
994 | 996 |
995 | 997 |
996 if use_ipv6: | 998 if use_ipv6: |
997 return IPv6HTTPServer((address, port), hgwebhandler) | 999 return IPv6HTTPServer((address, port), hgwebhandler) |