Mercurial > hg
changeset 938:54b2a42e501e
hgweb: add [web] section to hgrc
This makes almost all of the hgweb settings available in hgrc.
author | mpm@selenic.com |
---|---|
date | Wed, 17 Aug 2005 17:57:37 -0800 |
parents | e4f1b76831b2 |
children | 6b735e0ddd81 aedb47764f29 |
files | doc/hgrc.5.txt mercurial/commands.py mercurial/hgweb.py |
diffstat | 3 files changed, 48 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/hgrc.5.txt Wed Aug 17 16:37:04 2005 -0800 +++ b/doc/hgrc.5.txt Wed Aug 17 17:57:37 2005 -0800 @@ -110,6 +110,24 @@ verbose;; Increase the amount of output printed. True or False. Default is False. +web:: + Web interface configuration. + name;; + Repository name to use in the web interface. Default is current + working directory. + address;; + Interface address to bind to. Default is all. + port;; + Port to listen on. Default is 8000. + ipv6;; + Whether to use IPv6. Default is false. + accesslog;; + Where to output the access log. Default is stdout. + errorlog;; + Where to output the error log. Default is stderr. + templates;; + Where to find the HTML templates. Default is install path. + AUTHOR ------ Bryan O'Sullivan <bos@serpentine.com>.
--- a/mercurial/commands.py Wed Aug 17 16:37:04 2005 -0800 +++ b/mercurial/commands.py Wed Aug 17 17:57:37 2005 -0800 @@ -1087,16 +1087,9 @@ r = repo.addchangegroup(fin) respond("") - def openlog(opt, default): - if opts[opt] and opts[opt] != '-': - return open(opts[opt], 'w') - else: - return default - httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"], opts["address"], opts["port"], opts["ipv6"], - openlog('accesslog', sys.stdout), - openlog('errorlog', sys.stderr)) + opts['accesslog'], opts['errorlog']) if ui.verbose: addr, port = httpd.socket.getsockname() if addr == '0.0.0.0': @@ -1368,9 +1361,9 @@ (serve, [('A', 'accesslog', '', 'access log file'), ('E', 'errorlog', '', 'error log file'), - ('p', 'port', 8000, 'listen port'), + ('p', 'port', 0, 'listen port'), ('a', 'address', '', 'interface address'), - ('n', 'name', os.getcwd(), 'repository name'), + ('n', 'name', "", 'repository name'), ('', 'stdio', None, 'for remote clients'), ('t', 'templates', "", 'template map'), ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')],
--- a/mercurial/hgweb.py Wed Aug 17 16:37:04 2005 -0800 +++ b/mercurial/hgweb.py Wed Aug 17 17:57:37 2005 -0800 @@ -119,7 +119,7 @@ maxfiles = 10 def __init__(self, path, name, templates = ""): - self.templates = templates or templatepath() + self.templates = templates self.reponame = name self.path = path self.mtime = -1 @@ -603,7 +603,9 @@ self.refresh() args = cgi.parse() - m = os.path.join(self.templates, "map") + t = self.templates or self.repo.ui.config("web", "templates", + templatepath()) + m = os.path.join(t, "map") if args.has_key('style'): b = os.path.basename("map-" + args['style'][0]) p = os.path.join(self.templates, b) @@ -615,9 +617,11 @@ if "?" in uri: uri = uri.split("?")[0] url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) + name = self.reponame or self.repo.ui.config("web", "name", os.getcwd()) + self.t = templater(m, self.filters, {"url":url, - "repo":self.reponame, + "repo":name, "header":header, "footer":footer, }) @@ -705,6 +709,26 @@ def create_server(path, name, templates, address, port, use_ipv6 = False, accesslog = sys.stdout, errorlog = sys.stderr): + def openlog(opt, default): + if opt and opt != '-': + return open(opt, 'w') + return default + + u = ui() + repo = repository(u, path) + if not address: + address = u.config("web", "address", "") + if not port: + print port + port = int(u.config("web", "port", 8000)) + if not use_ipv6: + use_ipv6 = u.configbool("web", "ipv6") + + accesslog = openlog(accesslog or u.config("web", "accesslog", "-"), + sys.stdout) + errorlog = openlog(errorlog or u.config("web", "errorlog", "-"), + sys.stderr) + import BaseHTTPServer class IPv6HTTPServer(BaseHTTPServer.HTTPServer):