mercurial/commands.py
changeset 19919 e48c70451afc
parent 19893 dc4edca39e41
child 19935 4f53de036af8
equal deleted inserted replaced
19918:ae65192fd6b4 19919:e48c70451afc
  5181             raise error.RepoError(_("there is no Mercurial repository"
  5181             raise error.RepoError(_("there is no Mercurial repository"
  5182                                     " here (.hg not found)"))
  5182                                     " here (.hg not found)"))
  5183         o = repo
  5183         o = repo
  5184 
  5184 
  5185     app = hgweb.hgweb(o, baseui=baseui)
  5185     app = hgweb.hgweb(o, baseui=baseui)
  5186 
  5186     service = httpservice(ui, app, opts)
  5187     class service(object):
       
  5188         def init(self):
       
  5189             util.setsignalhandler()
       
  5190             self.httpd = hgweb_server.create_server(ui, app)
       
  5191 
       
  5192             if opts['port'] and not ui.verbose:
       
  5193                 return
       
  5194 
       
  5195             if self.httpd.prefix:
       
  5196                 prefix = self.httpd.prefix.strip('/') + '/'
       
  5197             else:
       
  5198                 prefix = ''
       
  5199 
       
  5200             port = ':%d' % self.httpd.port
       
  5201             if port == ':80':
       
  5202                 port = ''
       
  5203 
       
  5204             bindaddr = self.httpd.addr
       
  5205             if bindaddr == '0.0.0.0':
       
  5206                 bindaddr = '*'
       
  5207             elif ':' in bindaddr: # IPv6
       
  5208                 bindaddr = '[%s]' % bindaddr
       
  5209 
       
  5210             fqaddr = self.httpd.fqaddr
       
  5211             if ':' in fqaddr:
       
  5212                 fqaddr = '[%s]' % fqaddr
       
  5213             if opts['port']:
       
  5214                 write = ui.status
       
  5215             else:
       
  5216                 write = ui.write
       
  5217             write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
       
  5218                   (fqaddr, port, prefix, bindaddr, self.httpd.port))
       
  5219 
       
  5220         def run(self):
       
  5221             self.httpd.serve_forever()
       
  5222 
       
  5223     service = service()
       
  5224 
       
  5225     cmdutil.service(opts, initfn=service.init, runfn=service.run)
  5187     cmdutil.service(opts, initfn=service.init, runfn=service.run)
       
  5188 
       
  5189 class httpservice(object):
       
  5190     def __init__(self, ui, app, opts):
       
  5191         self.ui = ui
       
  5192         self.app = app
       
  5193         self.opts = opts
       
  5194 
       
  5195     def init(self):
       
  5196         util.setsignalhandler()
       
  5197         self.httpd = hgweb_server.create_server(self.ui, self.app)
       
  5198 
       
  5199         if self.opts['port'] and not self.ui.verbose:
       
  5200             return
       
  5201 
       
  5202         if self.httpd.prefix:
       
  5203             prefix = self.httpd.prefix.strip('/') + '/'
       
  5204         else:
       
  5205             prefix = ''
       
  5206 
       
  5207         port = ':%d' % self.httpd.port
       
  5208         if port == ':80':
       
  5209             port = ''
       
  5210 
       
  5211         bindaddr = self.httpd.addr
       
  5212         if bindaddr == '0.0.0.0':
       
  5213             bindaddr = '*'
       
  5214         elif ':' in bindaddr: # IPv6
       
  5215             bindaddr = '[%s]' % bindaddr
       
  5216 
       
  5217         fqaddr = self.httpd.fqaddr
       
  5218         if ':' in fqaddr:
       
  5219             fqaddr = '[%s]' % fqaddr
       
  5220         if self.opts['port']:
       
  5221             write = self.ui.status
       
  5222         else:
       
  5223             write = self.ui.write
       
  5224         write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
       
  5225               (fqaddr, port, prefix, bindaddr, self.httpd.port))
       
  5226 
       
  5227     def run(self):
       
  5228         self.httpd.serve_forever()
       
  5229 
  5226 
  5230 
  5227 @command('showconfig|debugconfig',
  5231 @command('showconfig|debugconfig',
  5228     [('u', 'untrusted', None, _('show untrusted configuration options'))],
  5232     [('u', 'untrusted', None, _('show untrusted configuration options'))],
  5229     _('[-u] [NAME]...'))
  5233     _('[-u] [NAME]...'))
  5230 def showconfig(ui, repo, *values, **opts):
  5234 def showconfig(ui, repo, *values, **opts):