Submitter | Yuya Nishihara |
---|---|
Date | Dec. 2, 2015, 1:20 p.m. |
Message ID | <fc3381d3883381bc757a.1449062457@mimosa> |
Download | mbox | patch |
Permalink | /patch/11744/ |
State | Superseded |
Commit | 64187e9a5659f523dd03665bb7778e50a6c5380d |
Headers | show |
Comments
On Wed, Dec 02, 2015 at 10:20:57PM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1446299403 -32400 > # Sat Oct 31 22:50:03 2015 +0900 > # Node ID fc3381d3883381bc757a8dc1969f6b1774a9ce06 > # Parent 1c8e143227acb790fa37fd262a49ec396c494039 > hgweb: load server settings from --web-conf (issue4699) queued these, thanks > > It copies the ui before loading the webconf and passes the copied ui only > to the service. This way, the hgwebdir app can reload configs cleanly. > > diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py > --- a/mercurial/hgweb/__init__.py > +++ b/mercurial/hgweb/__init__.py > @@ -96,6 +96,16 @@ def createservice(ui, repo, opts): > alluis.update([repo.baseui, repo.ui]) > else: > baseui = ui > + webconf = opts.get('web_conf') or opts.get('webdir_conf') > + if webconf: > + # load server settings (e.g. web.port) to "copied" ui, which allows > + # hgwebdir to reload webconf cleanly > + servui = ui.copy() > + servui.readconfig(webconf, sections=['web']) > + alluis.add(servui) > + else: > + servui = ui > + > optlist = ("name templates style address port prefix ipv6" > " accesslog errorlog certificate encoding") > for o in optlist.split(): > @@ -105,7 +115,6 @@ def createservice(ui, repo, opts): > for u in alluis: > u.setconfig("web", o, val, 'serve') > > - webconf = opts.get('web_conf') or opts.get('webdir_conf') > if webconf: > app = hgwebdir_mod.hgwebdir(webconf, baseui=baseui) > else: > @@ -113,4 +122,4 @@ def createservice(ui, repo, opts): > raise error.RepoError(_("there is no Mercurial repository" > " here (.hg not found)")) > app = hgweb_mod.hgweb(repo, baseui=baseui) > - return httpservice(ui, app, opts) > + return httpservice(servui, app, opts) > diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t > --- a/tests/test-hgwebdir.t > +++ b/tests/test-hgwebdir.t > @@ -1181,6 +1181,38 @@ test inexistent and inaccessible repo sh > </body> > </html> > > + > +test listening address/port specified by web-conf (issue4699): > + > + $ killdaemons.py > + $ cat >> paths.conf <<EOF > + > [web] > + > address = 127.0.0.1 > + > port = $HGPORT1 > + > EOF > + $ hg serve -d --pid-file=hg.pid --web-conf paths.conf \ > + > -A access-paths.log -E error-paths-9.log > + listening at http://localhost:$HGPORT1/ (bound to 127.0.0.1:$HGPORT1) > + $ cat hg.pid >> $DAEMON_PIDS > + $ get-with-headers.py localhost:$HGPORT1 '?style=raw' > + 200 Script output follows > + > + > + > +test --port option overrides web.port: > + > + $ killdaemons.py > + $ hg serve -p $HGPORT2 -d -v --pid-file=hg.pid --web-conf paths.conf \ > + > -A access-paths.log -E error-paths-10.log > + listening at http://localhost:$HGPORT2/ (bound to 127.0.0.1:$HGPORT2) > + $ cat hg.pid >> $DAEMON_PIDS > + $ get-with-headers.py localhost:$HGPORT2 '?style=raw' > + 200 Script output follows > + > + > + > + > + $ killdaemons.py > $ cat > collections.conf <<EOF > > [collections] > > $root=$root > @@ -1338,6 +1370,14 @@ paths errors 8 > > $ cat error-paths-8.log > > +paths errors 9 > + > + $ cat error-paths-9.log > + > +paths errors 10 > + > + $ cat error-paths-10.log > + > collections errors > > $ cat error-collections.log > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
On Wed, Dec 02, 2015 at 10:20:57PM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1446299403 -32400 > # Sat Oct 31 22:50:03 2015 +0900 > # Node ID fc3381d3883381bc757a8dc1969f6b1774a9ce06 > # Parent 1c8e143227acb790fa37fd262a49ec396c494039 > hgweb: load server settings from --web-conf (issue4699) This one breaks test-hgwebdir.t for me on both OS X and Linux. Can you take a look? (Discarding this patch for now.) > > It copies the ui before loading the webconf and passes the copied ui only > to the service. This way, the hgwebdir app can reload configs cleanly. > > diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py > --- a/mercurial/hgweb/__init__.py > +++ b/mercurial/hgweb/__init__.py > @@ -96,6 +96,16 @@ def createservice(ui, repo, opts): > alluis.update([repo.baseui, repo.ui]) > else: > baseui = ui > + webconf = opts.get('web_conf') or opts.get('webdir_conf') > + if webconf: > + # load server settings (e.g. web.port) to "copied" ui, which allows > + # hgwebdir to reload webconf cleanly > + servui = ui.copy() > + servui.readconfig(webconf, sections=['web']) > + alluis.add(servui) > + else: > + servui = ui > + > optlist = ("name templates style address port prefix ipv6" > " accesslog errorlog certificate encoding") > for o in optlist.split(): > @@ -105,7 +115,6 @@ def createservice(ui, repo, opts): > for u in alluis: > u.setconfig("web", o, val, 'serve') > > - webconf = opts.get('web_conf') or opts.get('webdir_conf') > if webconf: > app = hgwebdir_mod.hgwebdir(webconf, baseui=baseui) > else: > @@ -113,4 +122,4 @@ def createservice(ui, repo, opts): > raise error.RepoError(_("there is no Mercurial repository" > " here (.hg not found)")) > app = hgweb_mod.hgweb(repo, baseui=baseui) > - return httpservice(ui, app, opts) > + return httpservice(servui, app, opts) > diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t > --- a/tests/test-hgwebdir.t > +++ b/tests/test-hgwebdir.t > @@ -1181,6 +1181,38 @@ test inexistent and inaccessible repo sh > </body> > </html> > > + > +test listening address/port specified by web-conf (issue4699): > + > + $ killdaemons.py > + $ cat >> paths.conf <<EOF > + > [web] > + > address = 127.0.0.1 > + > port = $HGPORT1 > + > EOF > + $ hg serve -d --pid-file=hg.pid --web-conf paths.conf \ > + > -A access-paths.log -E error-paths-9.log > + listening at http://localhost:$HGPORT1/ (bound to 127.0.0.1:$HGPORT1) > + $ cat hg.pid >> $DAEMON_PIDS > + $ get-with-headers.py localhost:$HGPORT1 '?style=raw' > + 200 Script output follows > + > + > + > +test --port option overrides web.port: > + > + $ killdaemons.py > + $ hg serve -p $HGPORT2 -d -v --pid-file=hg.pid --web-conf paths.conf \ > + > -A access-paths.log -E error-paths-10.log > + listening at http://localhost:$HGPORT2/ (bound to 127.0.0.1:$HGPORT2) > + $ cat hg.pid >> $DAEMON_PIDS > + $ get-with-headers.py localhost:$HGPORT2 '?style=raw' > + 200 Script output follows > + > + > + > + > + $ killdaemons.py > $ cat > collections.conf <<EOF > > [collections] > > $root=$root > @@ -1338,6 +1370,14 @@ paths errors 8 > > $ cat error-paths-8.log > > +paths errors 9 > + > + $ cat error-paths-9.log > + > +paths errors 10 > + > + $ cat error-paths-10.log > + > collections errors > > $ cat error-collections.log > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py --- a/mercurial/hgweb/__init__.py +++ b/mercurial/hgweb/__init__.py @@ -96,6 +96,16 @@ def createservice(ui, repo, opts): alluis.update([repo.baseui, repo.ui]) else: baseui = ui + webconf = opts.get('web_conf') or opts.get('webdir_conf') + if webconf: + # load server settings (e.g. web.port) to "copied" ui, which allows + # hgwebdir to reload webconf cleanly + servui = ui.copy() + servui.readconfig(webconf, sections=['web']) + alluis.add(servui) + else: + servui = ui + optlist = ("name templates style address port prefix ipv6" " accesslog errorlog certificate encoding") for o in optlist.split(): @@ -105,7 +115,6 @@ def createservice(ui, repo, opts): for u in alluis: u.setconfig("web", o, val, 'serve') - webconf = opts.get('web_conf') or opts.get('webdir_conf') if webconf: app = hgwebdir_mod.hgwebdir(webconf, baseui=baseui) else: @@ -113,4 +122,4 @@ def createservice(ui, repo, opts): raise error.RepoError(_("there is no Mercurial repository" " here (.hg not found)")) app = hgweb_mod.hgweb(repo, baseui=baseui) - return httpservice(ui, app, opts) + return httpservice(servui, app, opts) diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t --- a/tests/test-hgwebdir.t +++ b/tests/test-hgwebdir.t @@ -1181,6 +1181,38 @@ test inexistent and inaccessible repo sh </body> </html> + +test listening address/port specified by web-conf (issue4699): + + $ killdaemons.py + $ cat >> paths.conf <<EOF + > [web] + > address = 127.0.0.1 + > port = $HGPORT1 + > EOF + $ hg serve -d --pid-file=hg.pid --web-conf paths.conf \ + > -A access-paths.log -E error-paths-9.log + listening at http://localhost:$HGPORT1/ (bound to 127.0.0.1:$HGPORT1) + $ cat hg.pid >> $DAEMON_PIDS + $ get-with-headers.py localhost:$HGPORT1 '?style=raw' + 200 Script output follows + + + +test --port option overrides web.port: + + $ killdaemons.py + $ hg serve -p $HGPORT2 -d -v --pid-file=hg.pid --web-conf paths.conf \ + > -A access-paths.log -E error-paths-10.log + listening at http://localhost:$HGPORT2/ (bound to 127.0.0.1:$HGPORT2) + $ cat hg.pid >> $DAEMON_PIDS + $ get-with-headers.py localhost:$HGPORT2 '?style=raw' + 200 Script output follows + + + + + $ killdaemons.py $ cat > collections.conf <<EOF > [collections] > $root=$root @@ -1338,6 +1370,14 @@ paths errors 8 $ cat error-paths-8.log +paths errors 9 + + $ cat error-paths-9.log + +paths errors 10 + + $ cat error-paths-10.log + collections errors $ cat error-collections.log