[PATCH] zeroconf: use port from server instead of picking port from config (issue3746)
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Sun Dec 30 22:01:35 UTC 2012
There was an unused import error from pyflakes, fixed and resent.
Cheers,
Benoit
On Sun, Dec 30, 2012 at 7:24 PM, Benoit Boissinot <
benoit.boissinot at ens-lyon.org> wrote:
> # HG changeset patch
> # User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
> # Date 1356891592 -3600
> # Branch stable
> # Node ID 8b50782825e6a625a29ec02134792928c4343d17
> # Parent 52581d2b98ac5355c3b2ea304595f8cfee4cce59
> zeroconf: use port from server instead of picking port from config
> (issue3746)
>
> In order to get the port, wrap create server instead of
> hgweb_mod/hgwebdir_mod.
>
> diff --git a/hgext/zeroconf/__init__.py b/hgext/zeroconf/__init__.py
> --- a/hgext/zeroconf/__init__.py
> +++ b/hgext/zeroconf/__init__.py
> @@ -29,8 +29,7 @@
> import Zeroconf
> from mercurial import ui, hg, encoding, util, dispatch
> from mercurial import extensions
> -from mercurial.hgweb import hgweb_mod
> -from mercurial.hgweb import hgwebdir_mod
> +from mercurial.hgweb import server as servermod
>
> testedwith = 'internal'
>
> @@ -102,27 +101,29 @@
> address = localip, weight = 0, priority =
> 0)
> server.registerService(svc)
>
> -class hgwebzc(hgweb_mod.hgweb):
> - def __init__(self, repo, name=None, baseui=None):
> - super(hgwebzc, self).__init__(repo, name=name, baseui=baseui)
> - name = self.reponame or os.path.basename(self.repo.root)
> - path = self.repo.ui.config("web", "prefix", "").strip('/')
> - desc = self.repo.ui.config("web", "description", name)
> - publish(name, desc, path,
> - util.getport(self.repo.ui.config("web", "port", 8000)))
> +def zc_create_server(create_server, ui, app):
> + httpd = create_server(ui, app)
> + port = httpd.port
>
> -class hgwebdirzc(hgwebdir_mod.hgwebdir):
> - def __init__(self, conf, baseui=None):
> - super(hgwebdirzc, self).__init__(conf, baseui=baseui)
> - prefix = self.ui.config("web", "prefix", "").strip('/') + '/'
> - for repo, path in self.repos:
> - u = self.ui.copy()
> + try:
> + repos = app.repos
> + except AttributeError:
> + # single repo
> + name = app.reponame or os.path.basename(app.repo.root)
> + path = app.repo.ui.config("web", "prefix", "").strip('/')
> + desc = app.repo.ui.config("web", "description", name)
> + publish(name, desc, path, port)
> + else:
> + # webdir
> + prefix = app.ui.config("web", "prefix", "").strip('/') + '/'
> + for repo, path in repos:
> + u = app.ui.copy()
> u.readconfig(os.path.join(path, '.hg', 'hgrc'))
> name = os.path.basename(repo)
> path = (prefix + repo).strip('/')
> desc = u.config('web', 'description', name)
> - publish(name, desc, path,
> - util.getport(u.config("web", "port", 8000)))
> + publish(name, desc, path, port)
> + return httpd
>
> # listen
>
> @@ -184,5 +185,4 @@
> extensions.wrapfunction(ui.ui, 'config', config)
> extensions.wrapfunction(ui.ui, 'configitems', configitems)
> extensions.wrapfunction(hg, 'defaultdest', defaultdest)
> -hgweb_mod.hgweb = hgwebzc
> -hgwebdir_mod.hgwebdir = hgwebdirzc
> +extensions.wrapfunction(servermod, 'create_server', zc_create_server)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20121230/4e5f8fad/attachment-0002.html>
More information about the Mercurial-devel
mailing list