Show More
@@ -27,10 +27,9 b' You can discover Zeroconf-enabled reposi' | |||||
27 | import socket, time, os |
|
27 | import socket, time, os | |
28 |
|
28 | |||
29 | import Zeroconf |
|
29 | import Zeroconf | |
30 |
from mercurial import ui, hg, encoding, |
|
30 | from mercurial import ui, hg, encoding, dispatch | |
31 | from mercurial import extensions |
|
31 | from mercurial import extensions | |
32 |
from mercurial.hgweb import |
|
32 | from mercurial.hgweb import server as servermod | |
33 | from mercurial.hgweb import hgwebdir_mod |
|
|||
34 |
|
33 | |||
35 | testedwith = 'internal' |
|
34 | testedwith = 'internal' | |
36 |
|
35 | |||
@@ -102,27 +101,29 b' def publish(name, desc, path, port):' | |||||
102 | address = localip, weight = 0, priority = 0) |
|
101 | address = localip, weight = 0, priority = 0) | |
103 | server.registerService(svc) |
|
102 | server.registerService(svc) | |
104 |
|
103 | |||
105 | class hgwebzc(hgweb_mod.hgweb): |
|
104 | def zc_create_server(create_server, ui, app): | |
106 | def __init__(self, repo, name=None, baseui=None): |
|
105 | httpd = create_server(ui, app) | |
107 | super(hgwebzc, self).__init__(repo, name=name, baseui=baseui) |
|
106 | port = httpd.port | |
108 | name = self.reponame or os.path.basename(self.repo.root) |
|
|||
109 | path = self.repo.ui.config("web", "prefix", "").strip('/') |
|
|||
110 | desc = self.repo.ui.config("web", "description", name) |
|
|||
111 | publish(name, desc, path, |
|
|||
112 | util.getport(self.repo.ui.config("web", "port", 8000))) |
|
|||
113 |
|
107 | |||
114 | class hgwebdirzc(hgwebdir_mod.hgwebdir): |
|
108 | try: | |
115 | def __init__(self, conf, baseui=None): |
|
109 | repos = app.repos | |
116 | super(hgwebdirzc, self).__init__(conf, baseui=baseui) |
|
110 | except AttributeError: | |
117 | prefix = self.ui.config("web", "prefix", "").strip('/') + '/' |
|
111 | # single repo | |
118 | for repo, path in self.repos: |
|
112 | name = app.reponame or os.path.basename(app.repo.root) | |
119 | u = self.ui.copy() |
|
113 | path = app.repo.ui.config("web", "prefix", "").strip('/') | |
|
114 | desc = app.repo.ui.config("web", "description", name) | |||
|
115 | publish(name, desc, path, port) | |||
|
116 | else: | |||
|
117 | # webdir | |||
|
118 | prefix = app.ui.config("web", "prefix", "").strip('/') + '/' | |||
|
119 | for repo, path in repos: | |||
|
120 | u = app.ui.copy() | |||
120 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) |
|
121 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) | |
121 | name = os.path.basename(repo) |
|
122 | name = os.path.basename(repo) | |
122 | path = (prefix + repo).strip('/') |
|
123 | path = (prefix + repo).strip('/') | |
123 | desc = u.config('web', 'description', name) |
|
124 | desc = u.config('web', 'description', name) | |
124 | publish(name, desc, path, |
|
125 | publish(name, desc, path, port) | |
125 | util.getport(u.config("web", "port", 8000))) |
|
126 | return httpd | |
126 |
|
127 | |||
127 | # listen |
|
128 | # listen | |
128 |
|
129 | |||
@@ -184,5 +185,4 b" extensions.wrapfunction(dispatch, '_runc" | |||||
184 | extensions.wrapfunction(ui.ui, 'config', config) |
|
185 | extensions.wrapfunction(ui.ui, 'config', config) | |
185 | extensions.wrapfunction(ui.ui, 'configitems', configitems) |
|
186 | extensions.wrapfunction(ui.ui, 'configitems', configitems) | |
186 | extensions.wrapfunction(hg, 'defaultdest', defaultdest) |
|
187 | extensions.wrapfunction(hg, 'defaultdest', defaultdest) | |
187 | hgweb_mod.hgweb = hgwebzc |
|
188 | extensions.wrapfunction(servermod, 'create_server', zc_create_server) | |
188 | hgwebdir_mod.hgwebdir = hgwebdirzc |
|
General Comments 0
You need to be logged in to leave comments.
Login now