##// END OF EJS Templates
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein -
r2127:8a85dbba default
parent child Browse files
Show More
@@ -2495,6 +2495,8 b' def serve(ui, repo, **opts):'
2495 2495 """
2496 2496
2497 2497 if opts["stdio"]:
2498 if repo is None:
2499 raise hg.RepoError(_('no repo found'))
2498 2500 fin, fout = sys.stdin, sys.stdout
2499 2501 sys.stdout = sys.stderr
2500 2502
@@ -2572,6 +2574,9 b' def serve(ui, repo, **opts):'
2572 2574 if opts[o]:
2573 2575 ui.setconfig("web", o, opts[o])
2574 2576
2577 if repo is None and not ui.config("web", "webdir_conf"):
2578 raise hg.RepoError(_('no repo found'))
2579
2575 2580 if opts['daemon'] and not opts['daemon_pipefds']:
2576 2581 rfd, wfd = os.pipe()
2577 2582 args = sys.argv[:]
@@ -2583,7 +2588,7 b' def serve(ui, repo, **opts):'
2583 2588 os._exit(0)
2584 2589
2585 2590 try:
2586 httpd = hgweb.create_server(repo)
2591 httpd = hgweb.create_server(ui, repo)
2587 2592 except socket.error, inst:
2588 2593 raise util.Abort(_('cannot start server: ') + inst.args[1])
2589 2594
@@ -3202,7 +3207,7 b' globalopts = ['
3202 3207
3203 3208 norepo = ("clone init version help debugancestor debugcomplete debugdata"
3204 3209 " debugindex debugindexdot")
3205 optionalrepo = ("paths debugconfig")
3210 optionalrepo = ("paths serve debugconfig")
3206 3211
3207 3212 def findpossible(cmd):
3208 3213 """
@@ -889,7 +889,7 b' class hgweb(object):'
889 889 else:
890 890 req.write(self.t("error"))
891 891
892 def create_server(repo):
892 def create_server(ui, repo):
893 893 use_threads = True
894 894
895 895 def openlog(opt, default):
@@ -897,12 +897,12 b' def create_server(repo):'
897 897 return open(opt, 'w')
898 898 return default
899 899
900 address = repo.ui.config("web", "address", "")
901 port = int(repo.ui.config("web", "port", 8000))
902 use_ipv6 = repo.ui.configbool("web", "ipv6")
903 webdir_conf = repo.ui.config("web", "webdir_conf")
904 accesslog = openlog(repo.ui.config("web", "accesslog", "-"), sys.stdout)
905 errorlog = openlog(repo.ui.config("web", "errorlog", "-"), sys.stderr)
900 address = ui.config("web", "address", "")
901 port = int(ui.config("web", "port", 8000))
902 use_ipv6 = ui.configbool("web", "ipv6")
903 webdir_conf = ui.config("web", "webdir_conf")
904 accesslog = openlog(ui.config("web", "accesslog", "-"), sys.stdout)
905 errorlog = openlog(ui.config("web", "errorlog", "-"), sys.stderr)
906 906
907 907 if use_threads:
908 908 try:
@@ -988,8 +988,10 b' def create_server(repo):'
988 988
989 989 if webdir_conf:
990 990 hgwebobj = hgwebdir(webdir_conf)
991 elif repo is not None:
992 hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot))
991 993 else:
992 hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot))
994 raise hg.RepoError(_('no repo found'))
993 995 hgwebobj.run(req)
994 996
995 997
General Comments 0
You need to be logged in to leave comments. Login now