diff mercurial/commands.py @ 38211:aea29e81753a

serve: add option print-url It can be used to open hgweb in a web browser. Example : xdg-open "`hg serve --print-url`". Differential Revision: https://phab.mercurial-scm.org/D3649
author Nicola Spanti <nicola.spanti@logilab.fr>
date Thu, 24 May 2018 09:56:28 +0000
parents dfb888aae17a
children 22edd5321489
line wrap: on
line diff
--- a/mercurial/commands.py	Sat May 26 11:33:02 2018 +0900
+++ b/mercurial/commands.py	Thu May 24 09:56:28 2018 +0000
@@ -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: