diff hgext/zeroconf/__init__.py @ 12076:49463314c24f

mail/hgweb: support service names for ports (issue2350) This adds util.getport(port) which tries to parse port as an int, and failing that, looks it up using socket.getservbyname(). Thus, the following will work: [smtp] port = submission [web] port = http This does not apply to ports in URLs used in clone, pull, etc.
author Brodie Rao <brodie@bitheap.org>
date Sat, 28 Aug 2010 12:31:07 -0400
parents 6bfb76cb8873
children 23fc62e0a960
line wrap: on
line diff
--- a/hgext/zeroconf/__init__.py	Fri Aug 27 16:25:47 2010 +0200
+++ b/hgext/zeroconf/__init__.py	Sat Aug 28 12:31:07 2010 -0400
@@ -27,7 +27,7 @@
 import socket, time, os
 
 import Zeroconf
-from mercurial import ui, hg, encoding
+from mercurial import ui, hg, encoding, util
 from mercurial import extensions
 from mercurial.hgweb import hgweb_mod
 from mercurial.hgweb import hgwebdir_mod
@@ -107,7 +107,7 @@
         path = self.repo.ui.config("web", "prefix", "").strip('/')
         desc = self.repo.ui.config("web", "description", name)
         publish(name, desc, path,
-                int(self.repo.ui.config("web", "port", 8000)))
+                util.getport(self.repo.ui.config("web", "port", 8000)))
 
 class hgwebdirzc(hgwebdir_mod.hgwebdir):
     def __init__(self, conf, baseui=None):
@@ -119,7 +119,7 @@
             name = os.path.basename(repo)
             path = (prefix + repo).strip('/')
             desc = u.config('web', 'description', name)
-            publish(name, desc, path, int(u.config("web", "port", 8000)))
+            publish(name, desc, path, util.getport(u.config("web", "port", 8000)))
 
 # listen