37 - list of virtual:real tuples (multi-repo view) |
37 - list of virtual:real tuples (multi-repo view) |
38 ''' |
38 ''' |
39 |
39 |
40 if isinstance(config, pycompat.unicode): |
40 if isinstance(config, pycompat.unicode): |
41 raise error.ProgrammingError( |
41 raise error.ProgrammingError( |
42 'Mercurial only supports encoded strings: %r' % config |
42 b'Mercurial only supports encoded strings: %r' % config |
43 ) |
43 ) |
44 if ( |
44 if ( |
45 (isinstance(config, bytes) and not os.path.isdir(config)) |
45 (isinstance(config, bytes) and not os.path.isdir(config)) |
46 or isinstance(config, dict) |
46 or isinstance(config, dict) |
47 or isinstance(config, list) |
47 or isinstance(config, list) |
64 def init(self): |
64 def init(self): |
65 procutil.setsignalhandler() |
65 procutil.setsignalhandler() |
66 self.httpd = server.create_server(self.ui, self.app) |
66 self.httpd = server.create_server(self.ui, self.app) |
67 |
67 |
68 if ( |
68 if ( |
69 self.opts['port'] |
69 self.opts[b'port'] |
70 and not self.ui.verbose |
70 and not self.ui.verbose |
71 and not self.opts['print_url'] |
71 and not self.opts[b'print_url'] |
72 ): |
72 ): |
73 return |
73 return |
74 |
74 |
75 if self.httpd.prefix: |
75 if self.httpd.prefix: |
76 prefix = self.httpd.prefix.strip('/') + '/' |
76 prefix = self.httpd.prefix.strip(b'/') + b'/' |
77 else: |
77 else: |
78 prefix = '' |
78 prefix = b'' |
79 |
79 |
80 port = r':%d' % self.httpd.port |
80 port = r':%d' % self.httpd.port |
81 if port == r':80': |
81 if port == r':80': |
82 port = r'' |
82 port = r'' |
83 |
83 |
89 |
89 |
90 fqaddr = self.httpd.fqaddr |
90 fqaddr = self.httpd.fqaddr |
91 if r':' in fqaddr: |
91 if r':' in fqaddr: |
92 fqaddr = r'[%s]' % fqaddr |
92 fqaddr = r'[%s]' % fqaddr |
93 |
93 |
94 url = 'http://%s%s/%s' % ( |
94 url = b'http://%s%s/%s' % ( |
95 pycompat.sysbytes(fqaddr), |
95 pycompat.sysbytes(fqaddr), |
96 pycompat.sysbytes(port), |
96 pycompat.sysbytes(port), |
97 prefix, |
97 prefix, |
98 ) |
98 ) |
99 if self.opts['print_url']: |
99 if self.opts[b'print_url']: |
100 self.ui.write('%s\n' % url) |
100 self.ui.write(b'%s\n' % url) |
101 else: |
101 else: |
102 if self.opts['port']: |
102 if self.opts[b'port']: |
103 write = self.ui.status |
103 write = self.ui.status |
104 else: |
104 else: |
105 write = self.ui.write |
105 write = self.ui.write |
106 write( |
106 write( |
107 _('listening at %s (bound to %s:%d)\n') |
107 _(b'listening at %s (bound to %s:%d)\n') |
108 % (url, pycompat.sysbytes(bindaddr), self.httpd.port) |
108 % (url, pycompat.sysbytes(bindaddr), self.httpd.port) |
109 ) |
109 ) |
110 self.ui.flush() # avoid buffering of status message |
110 self.ui.flush() # avoid buffering of status message |
111 |
111 |
112 def run(self): |
112 def run(self): |
117 if webconf: |
117 if webconf: |
118 return hgwebdir_mod.hgwebdir(webconf, baseui=baseui) |
118 return hgwebdir_mod.hgwebdir(webconf, baseui=baseui) |
119 else: |
119 else: |
120 if not repo: |
120 if not repo: |
121 raise error.RepoError( |
121 raise error.RepoError( |
122 _("there is no Mercurial repository" " here (.hg not found)") |
122 _(b"there is no Mercurial repository" b" here (.hg not found)") |
123 ) |
123 ) |
124 return hgweb_mod.hgweb(repo, baseui=baseui) |
124 return hgweb_mod.hgweb(repo, baseui=baseui) |