2020 optlist = "name templates style address port ipv6 accesslog errorlog" |
2020 optlist = "name templates style address port ipv6 accesslog errorlog" |
2021 for o in optlist.split(): |
2021 for o in optlist.split(): |
2022 if opts[o]: |
2022 if opts[o]: |
2023 ui.setconfig("web", o, opts[o]) |
2023 ui.setconfig("web", o, opts[o]) |
2024 |
2024 |
|
2025 if opts['daemon'] and not opts['daemon_pipefd']: |
|
2026 rfd, wfd = os.pipe() |
|
2027 args = sys.argv[:] |
|
2028 args.append('--daemon-pipefd=' + str(wfd)) |
|
2029 pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
|
2030 args[0], args) |
|
2031 os.close(wfd) |
|
2032 os.read(rfd, 1) |
|
2033 os._exit(0) |
|
2034 |
2025 try: |
2035 try: |
2026 httpd = hgweb.create_server(repo) |
2036 httpd = hgweb.create_server(repo) |
2027 except socket.error, inst: |
2037 except socket.error, inst: |
2028 raise util.Abort(_('cannot start server: ') + inst.args[1]) |
2038 raise util.Abort(_('cannot start server: ') + inst.args[1]) |
2029 |
2039 |
2038 pass |
2048 pass |
2039 if port != 80: |
2049 if port != 80: |
2040 ui.status(_('listening at http://%s:%d/\n') % (addr, port)) |
2050 ui.status(_('listening at http://%s:%d/\n') % (addr, port)) |
2041 else: |
2051 else: |
2042 ui.status(_('listening at http://%s/\n') % addr) |
2052 ui.status(_('listening at http://%s/\n') % addr) |
|
2053 |
|
2054 if opts['pid_file']: |
|
2055 fp = open(opts['pid_file'], 'w') |
|
2056 fp.write(str(os.getpid())) |
|
2057 fp.close() |
|
2058 |
|
2059 if opts['daemon_pipefd']: |
|
2060 wfd = int(opts['daemon_pipefd']) |
|
2061 os.write(wfd, 'y') |
|
2062 os.close(wfd) |
|
2063 sys.stdout.flush() |
|
2064 sys.stderr.flush() |
|
2065 fd = os.open(util.nulldev, os.O_RDWR) |
|
2066 if fd != 0: os.dup2(fd, 0) |
|
2067 if fd != 1: os.dup2(fd, 1) |
|
2068 if fd != 2: os.dup2(fd, 2) |
|
2069 if fd not in (0, 1, 2): os.close(fd) |
|
2070 |
2043 httpd.serve_forever() |
2071 httpd.serve_forever() |
2044 |
2072 |
2045 def status(ui, repo, *pats, **opts): |
2073 def status(ui, repo, *pats, **opts): |
2046 """show changed files in the working directory |
2074 """show changed files in the working directory |
2047 |
2075 |
2474 _('hg revert [-n] [-r REV] [NAME]...')), |
2502 _('hg revert [-n] [-r REV] [NAME]...')), |
2475 "root": (root, [], _('hg root')), |
2503 "root": (root, [], _('hg root')), |
2476 "^serve": |
2504 "^serve": |
2477 (serve, |
2505 (serve, |
2478 [('A', 'accesslog', '', _('name of access log file to write to')), |
2506 [('A', 'accesslog', '', _('name of access log file to write to')), |
|
2507 ('d', 'daemon', None, _('run server in background')), |
|
2508 ('', 'daemon-pipefd', '', ''), |
2479 ('E', 'errorlog', '', _('name of error log file to write to')), |
2509 ('E', 'errorlog', '', _('name of error log file to write to')), |
2480 ('p', 'port', 0, _('port to use (default: 8000)')), |
2510 ('p', 'port', 0, _('port to use (default: 8000)')), |
2481 ('a', 'address', '', _('address to use')), |
2511 ('a', 'address', '', _('address to use')), |
2482 ('n', 'name', '', |
2512 ('n', 'name', '', |
2483 _('name to show in web pages (default: working dir)')), |
2513 _('name to show in web pages (default: working dir)')), |
|
2514 ('', 'pid-file', '', _('name of file to write process ID to')), |
2484 ('', 'stdio', None, _('for remote clients')), |
2515 ('', 'stdio', None, _('for remote clients')), |
2485 ('t', 'templates', '', _('web templates to use')), |
2516 ('t', 'templates', '', _('web templates to use')), |
2486 ('', 'style', '', _('template style to use')), |
2517 ('', 'style', '', _('template style to use')), |
2487 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], |
2518 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], |
2488 _('hg serve [OPTION]...')), |
2519 _('hg serve [OPTION]...')), |