D3649: serve: add option print-url
durin42 added a comment. In https://phab.mercurial-scm.org/D3649#57906, @yuja wrote: > (resend because I forgot to remove the Phab shit, sorry for the noise.) > > > > It's surprising that `hg serve --print-url` spawns a daemon process! > > > > If it does not launch a daemon process, the procress caller (`xdg-open`, `midori`, `firefox`, etc.) waits the end of the stream to launch, so it waits that the `hg serve` procress ends! > > You can just run `hg serve -d --print-url`. > > The option could be named as `--daemon-print-url` if we needed such big > red switch, but I don't think that makes sense. On reflection I agree, it's a little too magical that --print-url daemonizes. Let's get a follow-up that doesn't do that, especially since -d is so easy to type. (I'd probably often use --print-url without --daemon, FWIW) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: admin, KelvinTot, av6, yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
av6 added a comment. In https://phab.mercurial-scm.org/D3649#57901, @nspanti-logilab wrote: > Could you describe tests that you would like? For example, some that check that url is correct and is printed on stdout and not stderr, maybe also that it is printed when --port is specified (unlike "listening at" line). Doesn't have to be a lot, just some usage of this new command line switch in the tests. For inspiration, there are examples in test-hgwebdir.t, lines 1414 and 1431. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: KelvinTot, av6, yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3649: serve: add option print-url
(resend because I forgot to remove the Phab shit, sorry for the noise.) > > It's surprising that `hg serve --print-url` spawns a daemon process! > > If it does not launch a daemon process, the procress caller (`xdg-open`, > `midori`, `firefox`, etc.) waits the end of the stream to launch, so it waits > that the `hg serve` procress ends! You can just run `hg serve -d --print-url`. The option could be named as `--daemon-print-url` if we needed such big red switch, but I don't think that makes sense. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
yuja added a comment. (resend because I forgot to remove the Phab shit, sorry for the noise.) > > It's surprising that `hg serve --print-url` spawns a daemon process! > > If it does not launch a daemon process, the procress caller (`xdg-open`, `midori`, `firefox`, etc.) waits the end of the stream to launch, so it waits that the `hg serve` procress ends! You can just run `hg serve -d --print-url`. The option could be named as `--daemon-print-url` if we needed such big red switch, but I don't think that makes sense. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: KelvinTot, av6, yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3649: serve: add option print-url
On Mon, 4 Jun 2018 09:34:19 +, nspanti-logilab (Nicola Spanti) wrote: > > It's surprising that `hg serve --print-url` spawns a daemon process! > > If it does not launch a daemon process, the procress caller (`xdg-open`, > `midori`, `firefox`, etc.) waits the end of the stream to launch, so it waits > that the `hg serve` procress ends! You can just run `hg serve -d --print-url`. The option could be named as `--daemon-print-url` if we needed such big red switch, but I don't think that makes sense. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
nspanti-logilab added a comment. In https://phab.mercurial-scm.org/D3649#57835, @yuja wrote: > It's surprising that `hg serve --print-url` spawns a daemon process! If it does not launch a daemon process, the procress caller (`xdg-open`, `midori`, `firefox`, etc.) waits the end of the stream to launch, so it waits that the `hg serve` procress ends! In https://phab.mercurial-scm.org/D3649#57838, @av6 wrote: > Merits another patch with some simple tests. Could you describe tests that you would like? @KelvinTot : Could you write in English or French, please? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: KelvinTot, av6, yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
KelvinTot added a comment. Приветствую! Класный у вас сайт! Нашёл интересное для дач и не только: [b] [b] мебельный щит сосна 20 мм [/b] [url=http://www.ekolestnica.ru/]http://www.ekolestnica.ru/[/url] Тут: https://www.ekolestnica.ru/lestnicy-ivanovo.html лестницы в иваново купить Здесь: [url=https://www.ekolestnica.ru/dveri-iz-massiva.html] межкомнатные двери из хвойного массива [/url] межкомнатные двери из хвойного массива Здесь: https://www.ekolestnica.ru/zaxodnye-stolby-dlya-lestnic.html REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: KelvinTot, av6, yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
av6 added a comment. Merits another patch with some simple tests. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: av6, yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
yuja added a comment. > ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), > ('', 'style', '', _('template style to use'), _('STYLE')), > ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), > > - ('', 'certificate', '', _('SSL certificate file'), _('FILE'))] +('', 'certificate', '', _('SSL certificate file'), _('FILE')), +('', 'print-url', None, _('start and print only the URL'))] + subrepoopts, _('[OPTION]...'), optionalrepo=True) @@ -4798,6 +4799,10 @@ opts = pycompat.byteskwargs(opts) if opts["stdio"] and opts["cmdserver"]: raise error.Abort(_("cannot use --stdio with --cmdserver")) +if opts["print_url"] and ui.verbose: +raise error.Abort(_("cannot use --print-url with --verbose")) +if opts["print_url"]: +opts['daemon'] = True It's surprising that `hg serve --print-url` spawns a daemon process! REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3649 To: nspanti-logilab, #hg-reviewers, durin42 Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3649: serve: add option print-url
> ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), > ('', 'style', '', _('template style to use'), _('STYLE')), > ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), > -('', 'certificate', '', _('SSL certificate file'), _('FILE'))] > +('', 'certificate', '', _('SSL certificate file'), _('FILE')), > +('', 'print-url', None, _('start and print only the URL'))] > + subrepoopts, > _('[OPTION]...'), > optionalrepo=True) > @@ -4798,6 +4799,10 @@ > opts = pycompat.byteskwargs(opts) > if opts["stdio"] and opts["cmdserver"]: > raise error.Abort(_("cannot use --stdio with --cmdserver")) > +if opts["print_url"] and ui.verbose: > +raise error.Abort(_("cannot use --print-url with --verbose")) > +if opts["print_url"]: > +opts['daemon'] = True It's surprising that `hg serve --print-url` spawns a daemon process! ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
This revision was automatically updated to reflect the committed changes. Closed by commit rHGaea29e81753a: serve: add option print-url (authored by nspanti-logilab, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D3649?vs=8880=8945#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3649?vs=8880=8945 REVISION DETAIL https://phab.mercurial-scm.org/D3649 AFFECTED FILES mercurial/commands.py mercurial/hgweb/__init__.py tests/test-completion.t CHANGE DETAILS diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -191,6 +191,7 @@ --pid-file --port --prefix + --print-url --profile --quiet --repository @@ -239,7 +240,7 @@ pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure remove: after, force, subrepos, include, exclude, dry-run - serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos + serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template summary: remote update: clean, check, merge, date, rev, tool diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py --- a/mercurial/hgweb/__init__.py +++ b/mercurial/hgweb/__init__.py @@ -57,7 +57,9 @@ procutil.setsignalhandler() self.httpd = server.create_server(self.ui, self.app) -if self.opts['port'] and not self.ui.verbose: +if (self.opts['port'] and +not self.ui.verbose and +not self.opts['print_url']): return if self.httpd.prefix: @@ -78,13 +80,18 @@ fqaddr = self.httpd.fqaddr if r':' in fqaddr: fqaddr = r'[%s]' % fqaddr -if self.opts['port']: -write = self.ui.status + +url = 'http://%s%s/%s' % ( +pycompat.sysbytes(fqaddr), pycompat.sysbytes(port), prefix) +if self.opts['print_url']: +self.ui.write('%s\n' % url) else: -write = self.ui.write -write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % - (pycompat.sysbytes(fqaddr), pycompat.sysbytes(port), - prefix, pycompat.sysbytes(bindaddr), self.httpd.port)) +if self.opts['port']: +write = self.ui.status +else: +write = self.ui.write +write(_('listening at %s (bound to %s:%d)\n') % + (url, pycompat.sysbytes(bindaddr), self.httpd.port)) self.ui.flush() # avoid buffering of status message def run(self): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4786,7 +4786,8 @@ ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), ('', 'style', '', _('template style to use'), _('STYLE')), ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), -('', 'certificate', '', _('SSL certificate file'), _('FILE'))] +('', 'certificate', '', _('SSL certificate file'), _('FILE')), +('', 'print-url', None, _('start and print only the URL'))] + subrepoopts, _('[OPTION]...'), optionalrepo=True) @@ -4818,6 +4819,10 @@ opts = pycompat.byteskwargs(opts) if opts["stdio"] and opts["cmdserver"]: raise error.Abort(_("cannot use --stdio with --cmdserver")) +if opts["print_url"] and ui.verbose: +raise error.Abort(_("cannot use --print-url with --verbose")) +if opts["print_url"]: +opts['daemon'] = True if opts["stdio"]: if repo is None: To: nspanti-logilab, #hg-reviewers, durin42 Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3649: serve: add option print-url
nspanti-logilab created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY It can be used to open hgweb in a web browser. Example : xdg-open "`hg serve --print-url`". REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D3649 AFFECTED FILES mercurial/commands.py mercurial/hgweb/__init__.py tests/test-completion.t CHANGE DETAILS diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -239,7 +239,7 @@ pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure remove: after, force, subrepos, include, exclude, dry-run - serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos + serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template summary: remote update: clean, check, merge, date, rev, tool diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py --- a/mercurial/hgweb/__init__.py +++ b/mercurial/hgweb/__init__.py @@ -57,7 +57,9 @@ procutil.setsignalhandler() self.httpd = server.create_server(self.ui, self.app) -if self.opts['port'] and not self.ui.verbose: +if(self.opts['port'] and + not self.ui.verbose and + not self.opts['print_url']): return if self.httpd.prefix: @@ -78,13 +80,18 @@ fqaddr = self.httpd.fqaddr if r':' in fqaddr: fqaddr = r'[%s]' % fqaddr -if self.opts['port']: -write = self.ui.status + +url = 'http://%s%s/%s' % ( +pycompat.sysbytes(fqaddr), pycompat.sysbytes(port), prefix) +if self.opts['print_url']: +self.ui.write('%s\n' % url) else: -write = self.ui.write -write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % - (pycompat.sysbytes(fqaddr), pycompat.sysbytes(port), - prefix, pycompat.sysbytes(bindaddr), self.httpd.port)) +if self.opts['port']: +write = self.ui.status +else: +write = self.ui.write +write(_('listening at %s (bound to %s:%d)\n') % + (url, pycompat.sysbytes(bindaddr), self.httpd.port)) self.ui.flush() # avoid buffering of status message def run(self): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4766,7 +4766,8 @@ ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), ('', 'style', '', _('template style to use'), _('STYLE')), ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), -('', 'certificate', '', _('SSL certificate file'), _('FILE'))] +('', 'certificate', '', _('SSL certificate file'), _('FILE')), +('', 'print-url', None, _('start and print only the URL'))] + subrepoopts, _('[OPTION]...'), optionalrepo=True) @@ -4798,6 +4799,10 @@ opts = pycompat.byteskwargs(opts) if opts["stdio"] and opts["cmdserver"]: raise error.Abort(_("cannot use --stdio with --cmdserver")) +if opts["print_url"] and ui.verbose: +raise error.Abort(_("cannot use --print-url with --verbose")) +if opts["print_url"]: +opts['daemon'] = True if opts["stdio"]: if repo is None: To: nspanti-logilab, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel