def init(self):
                util.setsignalhandler()
                self.httpd = server.create_server(self.ui, self.app)

                if self.opts['port'] and not self.ui.verbose:
                    return

                if self.httpd.prefix:
                    prefix = self.httpd.prefix.strip('/') + '/'
                else:
                    prefix = ''

                port = ':%d' % self.httpd.port
                if port == ':80':
                    port = ''

                bindaddr = self.httpd.addr
                if bindaddr == '0.0.0.0':
                    bindaddr = '*'
                elif ':' in bindaddr:  # IPv6
                    bindaddr = '[%s]' % bindaddr

                fqaddr = self.httpd.fqaddr
                if ':' in fqaddr:
                    fqaddr = '[%s]' % fqaddr
                if self.opts['port']:
                    write = self.ui.status
                else:
                    write = self.ui.write
                write('listening at http://%s%s/%s (bound to %s:%d)\n' %
                      (fqaddr, port, prefix, bindaddr, self.httpd.port))
            def init(self):
                util.setsignalhandler()
                self.httpd = server.create_server(self.ui, self.app)

                if self.opts['port'] and not self.ui.verbose:
                    return

                if self.httpd.prefix:
                    prefix = self.httpd.prefix.strip('/') + '/'
                else:
                    prefix = ''

                port = ':%d' % self.httpd.port
                if port == ':80':
                    port = ''

                bindaddr = self.httpd.addr
                if bindaddr == '0.0.0.0':
                    bindaddr = '*'
                elif ':' in bindaddr:  # IPv6
                    bindaddr = '[%s]' % bindaddr

                fqaddr = self.httpd.fqaddr
                if ':' in fqaddr:
                    fqaddr = '[%s]' % fqaddr
                if self.opts['port']:
                    write = self.ui.status
                else:
                    write = self.ui.write
                write('listening at http://%s%s/%s (bound to %s:%d)\n' %
                      (fqaddr, port, prefix, bindaddr, self.httpd.port))
Exemple #3
0
 def setUp(self):
     self.ui = myui()
     self.repodir = mkdtemp()
     # subclasses should override this to do real work
     self.setUpRepo()
     write_hgrc(self.repodir)
     self.repo = hg.repository(self.ui, self.repodir)
     # At some point create_server changed to take a hgweb.hgweb
     # as the second param instead of a repo. I don't know of a clean
     # way to feature test this, and this is just a unit test, so
     # the hacky way seems okay.
     argname = inspect.getargspec(server.create_server).args[1]
     arg = None
     if argname == "app":
         arg = hgweb.hgweb(self.repo.root, baseui=self.ui)
     elif argname == "repo":
         arg = self.repo
     if arg is None:
         # error, something unknown
         raise SystemExit(
             "Don't know how to run hgweb in this Mercurial version!")
     self.server = server.create_server(self.ui, arg)
     self.server.handle_error = handle_error
     _, self.port = self.server.socket.getsockname()
     # run the server on a background thread so we can interrupt it
     threading.Thread(target=self.server.serve_forever).start()
 def setUp(self):
     self.ui = myui()
     self.repodir = mkdtemp()
     # subclasses should override this to do real work
     self.setUpRepo()
     write_hgrc(self.repodir)
     self.repo = hg.repository(self.ui, self.repodir)
     # At some point create_server changed to take a hgweb.hgweb
     # as the second param instead of a repo. I don't know of a clean
     # way to feature test this, and this is just a unit test, so
     # the hacky way seems okay.
     argname = inspect.getargspec(server.create_server).args[1]
     arg = None
     if argname == "app":
         arg = hgweb.hgweb(self.repo.root, baseui=self.ui)
     elif argname == "repo":
         arg = self.repo
     if arg is None:
         # error, something unknown
         raise SystemExit("Don't know how to run hgweb in this Mercurial version!")
     self.server = server.create_server(self.ui, arg)
     self.server.handle_error = handle_error
     _, self.port = self.server.socket.getsockname()
     # run the server on a background thread so we can interrupt it
     threading.Thread(target=self.server.serve_forever).start()
Exemple #5
0
 def init(self):
     self.stopped = True
     util.set_signal_handler()
     try:
         parentui = ui.parentui or ui
         optlist = ("name templates style address port prefix ipv6"
                    " accesslog errorlog webdir_conf certificate")
         for o in optlist.split():
             if opts[o]:
                 parentui.setconfig("web", o, str(opts[o]))
                 if (repo is not None) and (repo.ui != parentui):
                     repo.ui.setconfig("web", o, str(opts[o]))
         self.httpd = server.create_server(ui, repo)
     except socket.error, inst:
         raise util.Abort(_('cannot start server: ') + inst.args[1])
Exemple #6
0
 def init(self):
     self.stopped = True
     util.set_signal_handler()
     try:
         baseui = repo and repo.baseui or ui
         repoui = repo and repo.ui != baseui and repo.ui or None
         optlist = ("name templates style address port prefix ipv6"
                    " accesslog errorlog webdir_conf certificate")
         for o in optlist.split():
             if opts[o]:
                 baseui.setconfig("web", o, str(opts[o]))
                 if repoui:
                     repoui.setconfig("web", o, str(opts[o]))
         o = opts.get('web_conf') or opts.get('webdir_conf')
         if o:
             app = hgwebdir_mod.hgwebdir(o, repo.ui)
         else:
             app = hgweb_mod.hgweb(hg.repository(repo.ui, repo.root))
         self.httpd = server.create_server(ui, app)
     except socket.error, inst:
         raise util.Abort(_('cannot start server: ') + inst.args[1])