[PATCH STABLE V2] zeroconf: use port from server instead of picking port from config (issue3746)

Benoit Boissinot benoit.boissinot at ens-lyon.org
Tue Jan 1 15:34:30 CST 2013


On Sun, Dec 30, 2012 at 11:54 PM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

>
> On 30 déc. 2012, at 23:00, Benoit Boissinot wrote:
>
> > -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
>
> It seems like you could factorise single repos vs multi repo case for
> improved clarity.
>

Since the two underlying classes differ quite a bit (ui in a different
place, etc.), there isn't much to refactor.

Cheers,

Benoit

>
> --
> Pierre-Yves David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130101/17e6eccc/attachment.html>


More information about the Mercurial-devel mailing list