##// END OF EJS Templates
serve: add option print-url...
Nicola Spanti -
r38196:aea29e81 default
parent child Browse files
Show More
@@ -4786,7 +4786,8 b' def root(ui, repo):'
4786 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4786 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4787 ('', 'style', '', _('template style to use'), _('STYLE')),
4787 ('', 'style', '', _('template style to use'), _('STYLE')),
4788 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4788 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4789 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))]
4789 ('', 'certificate', '', _('SSL certificate file'), _('FILE')),
4790 ('', 'print-url', None, _('start and print only the URL'))]
4790 + subrepoopts,
4791 + subrepoopts,
4791 _('[OPTION]...'),
4792 _('[OPTION]...'),
4792 optionalrepo=True)
4793 optionalrepo=True)
@@ -4818,6 +4819,10 b' def serve(ui, repo, **opts):'
4818 opts = pycompat.byteskwargs(opts)
4819 opts = pycompat.byteskwargs(opts)
4819 if opts["stdio"] and opts["cmdserver"]:
4820 if opts["stdio"] and opts["cmdserver"]:
4820 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4821 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4822 if opts["print_url"] and ui.verbose:
4823 raise error.Abort(_("cannot use --print-url with --verbose"))
4824 if opts["print_url"]:
4825 opts['daemon'] = True
4821
4826
4822 if opts["stdio"]:
4827 if opts["stdio"]:
4823 if repo is None:
4828 if repo is None:
@@ -57,7 +57,9 b' class httpservice(object):'
57 procutil.setsignalhandler()
57 procutil.setsignalhandler()
58 self.httpd = server.create_server(self.ui, self.app)
58 self.httpd = server.create_server(self.ui, self.app)
59
59
60 if self.opts['port'] and not self.ui.verbose:
60 if (self.opts['port'] and
61 not self.ui.verbose and
62 not self.opts['print_url']):
61 return
63 return
62
64
63 if self.httpd.prefix:
65 if self.httpd.prefix:
@@ -78,13 +80,18 b' class httpservice(object):'
78 fqaddr = self.httpd.fqaddr
80 fqaddr = self.httpd.fqaddr
79 if r':' in fqaddr:
81 if r':' in fqaddr:
80 fqaddr = r'[%s]' % fqaddr
82 fqaddr = r'[%s]' % fqaddr
83
84 url = 'http://%s%s/%s' % (
85 pycompat.sysbytes(fqaddr), pycompat.sysbytes(port), prefix)
86 if self.opts['print_url']:
87 self.ui.write('%s\n' % url)
88 else:
81 if self.opts['port']:
89 if self.opts['port']:
82 write = self.ui.status
90 write = self.ui.status
83 else:
91 else:
84 write = self.ui.write
92 write = self.ui.write
85 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
93 write(_('listening at %s (bound to %s:%d)\n') %
86 (pycompat.sysbytes(fqaddr), pycompat.sysbytes(port),
94 (url, pycompat.sysbytes(bindaddr), self.httpd.port))
87 prefix, pycompat.sysbytes(bindaddr), self.httpd.port))
88 self.ui.flush() # avoid buffering of status message
95 self.ui.flush() # avoid buffering of status message
89
96
90 def run(self):
97 def run(self):
@@ -191,6 +191,7 b' Show the options for the "serve" command'
191 --pid-file
191 --pid-file
192 --port
192 --port
193 --prefix
193 --prefix
194 --print-url
194 --profile
195 --profile
195 --quiet
196 --quiet
196 --repository
197 --repository
@@ -239,7 +240,7 b' Show all commands + options'
239 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
240 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
240 push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure
241 push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure
241 remove: after, force, subrepos, include, exclude, dry-run
242 remove: after, force, subrepos, include, exclude, dry-run
242 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos
243 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
243 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
244 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
244 summary: remote
245 summary: remote
245 update: clean, check, merge, date, rev, tool
246 update: clean, check, merge, date, rev, tool
General Comments 0
You need to be logged in to leave comments. Login now