##// END OF EJS Templates
zeroconf: code cleanup, fixing variable names to be meaningful
Alexander Solovyov -
r9488:33a6213a default
parent child Browse files
Show More
@@ -109,12 +109,12 b' class hgwebdirzc(hgwebdir_mod.hgwebdir):'
109 def __init__(self, conf, baseui=None):
109 def __init__(self, conf, baseui=None):
110 super(hgwebdirzc, self).__init__(conf, baseui)
110 super(hgwebdirzc, self).__init__(conf, baseui)
111 prefix = self.ui.config("web", "prefix", "").strip('/') + '/'
111 prefix = self.ui.config("web", "prefix", "").strip('/') + '/'
112 for r, p in self.repos:
112 for repo, path in self.repos:
113 u = self.ui.copy()
113 u = self.ui.copy()
114 u.readconfig(os.path.join(p, '.hg', 'hgrc'))
114 u.readconfig(os.path.join(path, '.hg', 'hgrc'))
115 n = os.path.basename(r)
115 name = os.path.basename(repo)
116 path = (prefix + r).strip('/')
116 path = (prefix + repo).strip('/')
117 publish(n, "hgweb", path, int(u.config("web", "port", 8000)))
117 publish(name, "hgweb", path, int(u.config("web", "port", 8000)))
118
118
119 # listen
119 # listen
120
120
@@ -136,25 +136,24 b' def getzcpaths():'
136 Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l)
136 Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l)
137 time.sleep(1)
137 time.sleep(1)
138 server.close()
138 server.close()
139 for v in l.found.values():
139 for value in l.found.values():
140 n = v.name[:v.name.index('.')]
140 name = value.name[:value.name.index('.')]
141 n.replace(" ", "-")
141 url = "http://%s:%s%s" % (socket.inet_ntoa(value.address), value.port,
142 u = "http://%s:%s%s" % (socket.inet_ntoa(v.address), v.port,
142 value.properties.get("path", "/"))
143 v.properties.get("path", "/"))
143 yield "zc-" + name, url
144 yield "zc-" + n, u
145
144
146 def config(orig, self, section, key, default=None, untrusted=False):
145 def config(orig, self, section, key, default=None, untrusted=False):
147 if section == "paths" and key.startswith("zc-"):
146 if section == "paths" and key.startswith("zc-"):
148 for n, p in getzcpaths():
147 for name, path in getzcpaths():
149 if n == key:
148 if name == key:
150 return p
149 return path
151 return orig(self, section, key, default, untrusted)
150 return orig(self, section, key, default, untrusted)
152
151
153 def configitems(orig, self, section, untrusted=False):
152 def configitems(orig, self, section, untrusted=False):
154 r = orig(self, section, untrusted)
153 repos = orig(self, section, untrusted)
155 if section == "paths":
154 if section == "paths":
156 r += getzcpaths()
155 repos += getzcpaths()
157 return r
156 return repos
158
157
159 extensions.wrapfunction(ui.ui, 'config', config)
158 extensions.wrapfunction(ui.ui, 'config', config)
160 extensions.wrapfunction(ui.ui, 'configitems', configitems)
159 extensions.wrapfunction(ui.ui, 'configitems', configitems)
General Comments 0
You need to be logged in to leave comments. Login now