It can be used to open hgweb in a web browser. Example :
xdg-open "hg serve --print-url".
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHGaea29e81753a: serve: add option print-url
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
('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!
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!
Could you describe tests that you would like?
@KelvinTot : Could you write in English or French, please?
(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.
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.
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)