Show More
@@ -330,6 +330,7 b' serve [options]::' | |||
|
330 | 330 | -p, --port <n> port to use (default: 8000) |
|
331 | 331 | -n, --name <name> name to show in web pages (default: working dir) |
|
332 | 332 | -t, --templatedir <path> web templates to use |
|
333 | -6, --ipv6 use IPv6 in addition to IPv4 | |
|
333 | 334 | |
|
334 | 335 | status [options] [files]:: |
|
335 | 336 | Show changed files in the working directory. If no names are |
@@ -1002,7 +1002,7 b' def serve(ui, repo, **opts):' | |||
|
1002 | 1002 | return default |
|
1003 | 1003 | |
|
1004 | 1004 | httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"], |
|
1005 | opts["address"], opts["port"], | |
|
1005 | opts["address"], opts["port"], opts["ipv6"], | |
|
1006 | 1006 | openlog('accesslog', sys.stdout), |
|
1007 | 1007 | openlog('errorlog', sys.stderr)) |
|
1008 | 1008 | if ui.verbose: |
@@ -1251,7 +1251,8 b' table = {' | |||
|
1251 | 1251 | ('a', 'address', '', 'interface address'), |
|
1252 | 1252 | ('n', 'name', os.getcwd(), 'repository name'), |
|
1253 | 1253 | ('', 'stdio', None, 'for remote clients'), |
|
1254 |
('t', 'templates', "", 'template map') |
|
|
1254 | ('t', 'templates', "", 'template map'), | |
|
1255 | ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')], | |
|
1255 | 1256 | "hg serve [OPTION]..."), |
|
1256 | 1257 | "^status": (status, |
|
1257 | 1258 | [('I', 'include', [], 'include path in search'), |
@@ -6,7 +6,7 b'' | |||
|
6 | 6 | # This software may be used and distributed according to the terms |
|
7 | 7 | # of the GNU General Public License, incorporated herein by reference. |
|
8 | 8 | |
|
9 | import os, cgi, time, re, difflib, sys, zlib | |
|
9 | import os, cgi, time, re, difflib, socket, sys, zlib | |
|
10 | 10 | from mercurial.hg import * |
|
11 | 11 | from mercurial.ui import * |
|
12 | 12 | |
@@ -699,11 +699,14 b' class hgweb:' | |||
|
699 | 699 | else: |
|
700 | 700 | write(self.t("error")) |
|
701 | 701 | |
|
702 | def create_server(path, name, templates, address, port, | |
|
702 | def create_server(path, name, templates, address, port, use_ipv6 = False, | |
|
703 | 703 | accesslog = sys.stdout, errorlog = sys.stderr): |
|
704 | 704 | |
|
705 | 705 | import BaseHTTPServer |
|
706 | 706 | |
|
707 | class IPv6HTTPServer(BaseHTTPServer.HTTPServer): | |
|
708 | address_family = socket.AF_INET6 | |
|
709 | ||
|
707 | 710 | class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler): |
|
708 | 711 | def log_error(self, format, *args): |
|
709 | 712 | errorlog.write("%s - - [%s] %s\n" % (self.address_string(), |
@@ -774,10 +777,13 b' def create_server(path, name, templates,' | |||
|
774 | 777 | sys.argv, sys.stdin, sys.stdout, sys.stderr = save |
|
775 | 778 | |
|
776 | 779 | hg = hgweb(path, name, templates) |
|
777 | return BaseHTTPServer.HTTPServer((address, port), hgwebhandler) | |
|
780 | if use_ipv6: | |
|
781 | return IPv6HTTPServer((address, port), hgwebhandler) | |
|
782 | else: | |
|
783 | return BaseHTTPServer.HTTPServer((address, port), hgwebhandler) | |
|
778 | 784 | |
|
779 | def server(path, name, templates, address, port, | |
|
785 | def server(path, name, templates, address, port, use_ipv6 = False, | |
|
780 | 786 | accesslog = sys.stdout, errorlog = sys.stderr): |
|
781 | httpd = create_server(path, name, templates, address, port, | |
|
787 | httpd = create_server(path, name, templates, address, port, use_ipv6, | |
|
782 | 788 | accesslog, errorlog) |
|
783 | 789 | httpd.serve_forever() |
General Comments 0
You need to be logged in to leave comments.
Login now