Show More
@@ -15,7 +15,6 b' import patch, help, encoding, templatekw' | |||||
15 | import archival, changegroup, cmdutil, hbisect |
|
15 | import archival, changegroup, cmdutil, hbisect | |
16 | import sshserver, hgweb |
|
16 | import sshserver, hgweb | |
17 | import extensions |
|
17 | import extensions | |
18 | from hgweb import server as hgweb_server |
|
|||
19 | import merge as mergemod |
|
18 | import merge as mergemod | |
20 | import minirst, revset, fileset |
|
19 | import minirst, revset, fileset | |
21 | import dagparser, context, simplemerge, graphmod, copies |
|
20 | import dagparser, context, simplemerge, graphmod, copies | |
@@ -6001,52 +6000,9 b' def serve(ui, repo, **opts):' | |||||
6001 | o = repo |
|
6000 | o = repo | |
6002 |
|
6001 | |||
6003 | app = hgweb.hgweb(o, baseui=baseui) |
|
6002 | app = hgweb.hgweb(o, baseui=baseui) | |
6004 | service = httpservice(ui, app, opts) |
|
6003 | service = hgweb.httpservice(ui, app, opts) | |
6005 | cmdutil.service(opts, initfn=service.init, runfn=service.run) |
|
6004 | cmdutil.service(opts, initfn=service.init, runfn=service.run) | |
6006 |
|
6005 | |||
6007 | class httpservice(object): |
|
|||
6008 | def __init__(self, ui, app, opts): |
|
|||
6009 | self.ui = ui |
|
|||
6010 | self.app = app |
|
|||
6011 | self.opts = opts |
|
|||
6012 |
|
||||
6013 | def init(self): |
|
|||
6014 | util.setsignalhandler() |
|
|||
6015 | self.httpd = hgweb_server.create_server(self.ui, self.app) |
|
|||
6016 |
|
||||
6017 | if self.opts['port'] and not self.ui.verbose: |
|
|||
6018 | return |
|
|||
6019 |
|
||||
6020 | if self.httpd.prefix: |
|
|||
6021 | prefix = self.httpd.prefix.strip('/') + '/' |
|
|||
6022 | else: |
|
|||
6023 | prefix = '' |
|
|||
6024 |
|
||||
6025 | port = ':%d' % self.httpd.port |
|
|||
6026 | if port == ':80': |
|
|||
6027 | port = '' |
|
|||
6028 |
|
||||
6029 | bindaddr = self.httpd.addr |
|
|||
6030 | if bindaddr == '0.0.0.0': |
|
|||
6031 | bindaddr = '*' |
|
|||
6032 | elif ':' in bindaddr: # IPv6 |
|
|||
6033 | bindaddr = '[%s]' % bindaddr |
|
|||
6034 |
|
||||
6035 | fqaddr = self.httpd.fqaddr |
|
|||
6036 | if ':' in fqaddr: |
|
|||
6037 | fqaddr = '[%s]' % fqaddr |
|
|||
6038 | if self.opts['port']: |
|
|||
6039 | write = self.ui.status |
|
|||
6040 | else: |
|
|||
6041 | write = self.ui.write |
|
|||
6042 | write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % |
|
|||
6043 | (fqaddr, port, prefix, bindaddr, self.httpd.port)) |
|
|||
6044 | self.ui.flush() # avoid buffering of status message |
|
|||
6045 |
|
||||
6046 | def run(self): |
|
|||
6047 | self.httpd.serve_forever() |
|
|||
6048 |
|
||||
6049 |
|
||||
6050 | @command('^status|st', |
|
6006 | @command('^status|st', | |
6051 | [('A', 'all', None, _('show status of all files')), |
|
6007 | [('A', 'all', None, _('show status of all files')), | |
6052 | ('m', 'modified', None, _('show only modified files')), |
|
6008 | ('m', 'modified', None, _('show only modified files')), |
@@ -10,9 +10,16 b' from __future__ import absolute_import' | |||||
10 |
|
10 | |||
11 | import os |
|
11 | import os | |
12 |
|
12 | |||
|
13 | from ..i18n import _ | |||
|
14 | ||||
|
15 | from .. import ( | |||
|
16 | util, | |||
|
17 | ) | |||
|
18 | ||||
13 | from . import ( |
|
19 | from . import ( | |
14 | hgweb_mod, |
|
20 | hgweb_mod, | |
15 | hgwebdir_mod, |
|
21 | hgwebdir_mod, | |
|
22 | server, | |||
16 | ) |
|
23 | ) | |
17 |
|
24 | |||
18 | def hgweb(config, name=None, baseui=None): |
|
25 | def hgweb(config, name=None, baseui=None): | |
@@ -35,3 +42,44 b' def hgweb(config, name=None, baseui=None' | |||||
35 | def hgwebdir(config, baseui=None): |
|
42 | def hgwebdir(config, baseui=None): | |
36 | return hgwebdir_mod.hgwebdir(config, baseui=baseui) |
|
43 | return hgwebdir_mod.hgwebdir(config, baseui=baseui) | |
37 |
|
44 | |||
|
45 | class httpservice(object): | |||
|
46 | def __init__(self, ui, app, opts): | |||
|
47 | self.ui = ui | |||
|
48 | self.app = app | |||
|
49 | self.opts = opts | |||
|
50 | ||||
|
51 | def init(self): | |||
|
52 | util.setsignalhandler() | |||
|
53 | self.httpd = server.create_server(self.ui, self.app) | |||
|
54 | ||||
|
55 | if self.opts['port'] and not self.ui.verbose: | |||
|
56 | return | |||
|
57 | ||||
|
58 | if self.httpd.prefix: | |||
|
59 | prefix = self.httpd.prefix.strip('/') + '/' | |||
|
60 | else: | |||
|
61 | prefix = '' | |||
|
62 | ||||
|
63 | port = ':%d' % self.httpd.port | |||
|
64 | if port == ':80': | |||
|
65 | port = '' | |||
|
66 | ||||
|
67 | bindaddr = self.httpd.addr | |||
|
68 | if bindaddr == '0.0.0.0': | |||
|
69 | bindaddr = '*' | |||
|
70 | elif ':' in bindaddr: # IPv6 | |||
|
71 | bindaddr = '[%s]' % bindaddr | |||
|
72 | ||||
|
73 | fqaddr = self.httpd.fqaddr | |||
|
74 | if ':' in fqaddr: | |||
|
75 | fqaddr = '[%s]' % fqaddr | |||
|
76 | if self.opts['port']: | |||
|
77 | write = self.ui.status | |||
|
78 | else: | |||
|
79 | write = self.ui.write | |||
|
80 | write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % | |||
|
81 | (fqaddr, port, prefix, bindaddr, self.httpd.port)) | |||
|
82 | self.ui.flush() # avoid buffering of status message | |||
|
83 | ||||
|
84 | def run(self): | |||
|
85 | self.httpd.serve_forever() |
General Comments 0
You need to be logged in to leave comments.
Login now