Mercurial > hg
comparison mercurial/hgweb/server.py @ 6217:fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
author | Joel Rosdahl <joel@rosdahl.net> |
---|---|
date | Thu, 06 Mar 2008 22:51:16 +0100 |
parents | e75aab656f46 |
children | de7256c82fad |
comparison
equal
deleted
inserted
replaced
6216:a88259018f79 | 6217:fe8dbbe9520d |
---|---|
6 # This software may be used and distributed according to the terms | 6 # This software may be used and distributed according to the terms |
7 # of the GNU General Public License, incorporated herein by reference. | 7 # of the GNU General Public License, incorporated herein by reference. |
8 | 8 |
9 import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer, traceback | 9 import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer, traceback |
10 from mercurial import hg, util | 10 from mercurial import hg, util |
11 from mercurial.repo import RepoError | |
11 from hgweb_mod import hgweb | 12 from hgweb_mod import hgweb |
12 from hgwebdir_mod import hgwebdir | 13 from hgwebdir_mod import hgwebdir |
13 from mercurial.i18n import gettext as _ | 14 from mercurial.i18n import gettext as _ |
14 | 15 |
15 def _splitURI(uri): | 16 def _splitURI(uri): |
245 if webdir_conf: | 246 if webdir_conf: |
246 hgwebobj = hgwebdir(webdir_conf, ui) | 247 hgwebobj = hgwebdir(webdir_conf, ui) |
247 elif repo is not None: | 248 elif repo is not None: |
248 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | 249 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) |
249 else: | 250 else: |
250 raise hg.RepoError(_("There is no Mercurial repository here" | 251 raise RepoError(_("There is no Mercurial repository here" |
251 " (.hg not found)")) | 252 " (.hg not found)")) |
252 return hgwebobj | 253 return hgwebobj |
253 self.application = make_handler() | 254 self.application = make_handler() |
254 | 255 |
255 addr = address | 256 addr = address |
256 if addr in ('', '::'): | 257 if addr in ('', '::'): |
275 class IPv6HTTPServer(MercurialHTTPServer): | 276 class IPv6HTTPServer(MercurialHTTPServer): |
276 address_family = getattr(socket, 'AF_INET6', None) | 277 address_family = getattr(socket, 'AF_INET6', None) |
277 | 278 |
278 def __init__(self, *args, **kwargs): | 279 def __init__(self, *args, **kwargs): |
279 if self.address_family is None: | 280 if self.address_family is None: |
280 raise hg.RepoError(_('IPv6 not available on this system')) | 281 raise RepoError(_('IPv6 not available on this system')) |
281 super(IPv6HTTPServer, self).__init__(*args, **kwargs) | 282 super(IPv6HTTPServer, self).__init__(*args, **kwargs) |
282 | 283 |
283 if ssl_cert: | 284 if ssl_cert: |
284 handler = _shgwebhandler | 285 handler = _shgwebhandler |
285 else: | 286 else: |