Show More
@@ -1117,9 +1117,13 b' def serve(ui, repo, **opts):' | |||
|
1117 | 1117 | r = repo.addchangegroup(fin) |
|
1118 | 1118 | respond("") |
|
1119 | 1119 | |
|
1120 | httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"], | |
|
1121 | opts["address"], opts["port"], opts["ipv6"], | |
|
1122 | opts['accesslog'], opts['errorlog']) | |
|
1120 | optlist = "name templates style address port ipv6 accesslog errorlog" | |
|
1121 | for o in optlist.split(): | |
|
1122 | if opts[o]: | |
|
1123 | ui.setconfig("web", o, opts[o]) | |
|
1124 | ||
|
1125 | httpd = hgweb.create_server(repo) | |
|
1126 | ||
|
1123 | 1127 | if ui.verbose: |
|
1124 | 1128 | addr, port = httpd.socket.getsockname() |
|
1125 | 1129 | if addr == '0.0.0.0': |
@@ -1402,7 +1406,8 b' table = {' | |||
|
1402 | 1406 | ('a', 'address', '', 'interface address'), |
|
1403 | 1407 | ('n', 'name', "", 'repository name'), |
|
1404 | 1408 | ('', 'stdio', None, 'for remote clients'), |
|
1405 |
('t', 'templates', "", 'template |
|
|
1409 | ('t', 'templates', "", 'template directory'), | |
|
1410 | ('', 'style', "", 'template style'), | |
|
1406 | 1411 | ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')], |
|
1407 | 1412 | "hg serve [OPTION]..."), |
|
1408 | 1413 | "^status": |
@@ -138,19 +138,21 b' common_filters = {' | |||
|
138 | 138 | } |
|
139 | 139 | |
|
140 | 140 | class hgweb: |
|
141 | def __init__(self, repo, name=None): | |
|
142 | if type(repo) == type(""): | |
|
143 | self.repo = repository(ui(), repo) | |
|
144 | else: | |
|
145 | self.repo = repo | |
|
141 | 146 | |
|
142 | def __init__(self, path, name=None, templates=""): | |
|
143 | self.templates = templates | |
|
144 | self.reponame = name | |
|
145 | self.path = path | |
|
146 | 147 | self.mtime = -1 |
|
147 | self.viewonly = 0 | |
|
148 | self.reponame = name or self.repo.ui.config("web", "name", | |
|
149 | self.repo.root) | |
|
148 | 150 | |
|
149 | 151 | def refresh(self): |
|
150 |
s = os.stat(os.path.join(self. |
|
|
152 | s = os.stat(os.path.join(self.repo.root, ".hg", "00changelog.i")) | |
|
151 | 153 | if s.st_mtime != self.mtime: |
|
152 | 154 | self.mtime = s.st_mtime |
|
153 |
self.repo = repository(ui |
|
|
155 | self.repo = repository(self.repo.ui, self.repo.root) | |
|
154 | 156 | self.maxchanges = self.repo.ui.config("web", "maxchanges", 10) |
|
155 | 157 | self.maxfiles = self.repo.ui.config("web", "maxchanges", 10) |
|
156 | 158 | self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
@@ -623,8 +625,7 b' class hgweb:' | |||
|
623 | 625 | self.refresh() |
|
624 | 626 | args = cgi.parse() |
|
625 | 627 | |
|
626 |
t = |
|
|
627 | templatepath()) | |
|
628 | t = self.repo.ui.config("web", "templates", templatepath()) | |
|
628 | 629 | m = os.path.join(t, "map") |
|
629 | 630 | style = self.repo.ui.config("web", "style", "") |
|
630 | 631 | if args.has_key('style'): |
@@ -640,11 +641,9 b' class hgweb:' | |||
|
640 | 641 | if "?" in uri: uri = uri.split("?")[0] |
|
641 | 642 | url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) |
|
642 | 643 | |
|
643 | name = self.reponame or self.repo.ui.config("web", "name", os.getcwd()) | |
|
644 | ||
|
645 | 644 | self.t = templater(m, common_filters, |
|
646 | 645 | {"url":url, |
|
647 | "repo":name, | |
|
646 | "repo":self.reponame, | |
|
648 | 647 | "header":header, |
|
649 | 648 | "footer":footer, |
|
650 | 649 | }) |
@@ -729,27 +728,18 b' class hgweb:' | |||
|
729 | 728 | else: |
|
730 | 729 | write(self.t("error")) |
|
731 | 730 | |
|
732 | def create_server(path, name, templates, address, port, use_ipv6 = False, | |
|
733 | accesslog = sys.stdout, errorlog = sys.stderr): | |
|
731 | def create_server(repo): | |
|
734 | 732 | |
|
735 | 733 | def openlog(opt, default): |
|
736 | 734 | if opt and opt != '-': |
|
737 | 735 | return open(opt, 'w') |
|
738 | 736 | return default |
|
739 | 737 | |
|
740 | u = ui() | |
|
741 | repo = repository(u, path) | |
|
742 | if not address: | |
|
743 |
|
|
|
744 | if not port: | |
|
745 | port = int(u.config("web", "port", 8000)) | |
|
746 | if not use_ipv6: | |
|
747 | use_ipv6 = u.configbool("web", "ipv6") | |
|
748 | ||
|
749 | accesslog = openlog(accesslog or u.config("web", "accesslog", "-"), | |
|
750 | sys.stdout) | |
|
751 | errorlog = openlog(errorlog or u.config("web", "errorlog", "-"), | |
|
752 | sys.stderr) | |
|
738 | address = repo.ui.config("web", "address", "") | |
|
739 | port = int(repo.ui.config("web", "port", 8000)) | |
|
740 | use_ipv6 = repo.ui.configbool("web", "ipv6") | |
|
741 | accesslog = openlog(repo.ui.config("web", "accesslog", "-"), sys.stdout) | |
|
742 | errorlog = openlog(repo.ui.config("web", "errorlog", "-"), sys.stderr) | |
|
753 | 743 | |
|
754 | 744 | import BaseHTTPServer |
|
755 | 745 | |
@@ -830,7 +820,7 b' def create_server(path, name, templates,' | |||
|
830 | 820 | finally: |
|
831 | 821 | sys.argv, sys.stdin, sys.stdout, sys.stderr = save |
|
832 | 822 | |
|
833 | hg = hgweb(path, name, templates) | |
|
823 | hg = hgweb(repo) | |
|
834 | 824 | if use_ipv6: |
|
835 | 825 | return IPv6HTTPServer((address, port), hgwebhandler) |
|
836 | 826 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now