Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 10644:63948e7d37f7
server: initialize wsgi app in command, then wrap server around it
author | Dirkjan Ochtman <djc.ochtman@kentyde.com> |
---|---|
date | Thu, 11 Mar 2010 13:33:29 +0100 |
parents | 27027bee318e |
children | e13797685ee6 |
comparison
equal
deleted
inserted
replaced
10643:1874697a8863 | 10644:63948e7d37f7 |
---|---|
10 from i18n import _, gettext | 10 from i18n import _, gettext |
11 import os, re, sys, difflib, time, tempfile | 11 import os, re, sys, difflib, time, tempfile |
12 import hg, util, revlog, bundlerepo, extensions, copies, error | 12 import hg, util, revlog, bundlerepo, extensions, copies, error |
13 import patch, help, mdiff, url, encoding, templatekw | 13 import patch, help, mdiff, url, encoding, templatekw |
14 import archival, changegroup, cmdutil, sshserver, hbisect | 14 import archival, changegroup, cmdutil, sshserver, hbisect |
15 from hgweb import server | 15 from hgweb import server, hgweb_mod, hgwebdir_mod |
16 import merge as merge_ | 16 import merge as merge_ |
17 import minirst | 17 import minirst |
18 | 18 |
19 # Commands start here, listed alphabetically | 19 # Commands start here, listed alphabetically |
20 | 20 |
2885 if opts.get('port'): | 2885 if opts.get('port'): |
2886 opts['port'] = int(opts.get('port')) | 2886 opts['port'] = int(opts.get('port')) |
2887 | 2887 |
2888 baseui = repo and repo.baseui or ui | 2888 baseui = repo and repo.baseui or ui |
2889 optlist = ("name templates style address port prefix ipv6" | 2889 optlist = ("name templates style address port prefix ipv6" |
2890 " accesslog errorlog webdir_conf certificate encoding") | 2890 " accesslog errorlog certificate encoding") |
2891 for o in optlist.split(): | 2891 for o in optlist.split(): |
2892 val = opts.get(o, '') | 2892 val = opts.get(o, '') |
2893 if val in (None, ''): # should check against default options instead | 2893 if val in (None, ''): # should check against default options instead |
2894 continue | 2894 continue |
2895 baseui.setconfig("web", o, val) | 2895 baseui.setconfig("web", o, val) |
2896 if repo and repo.ui != baseui: | 2896 if repo and repo.ui != baseui: |
2897 repo.ui.setconfig("web", o, val) | 2897 repo.ui.setconfig("web", o, val) |
2898 | 2898 |
2899 if repo is None and not ui.config("web", "webdir_conf"): | 2899 if opts.get('webdir_conf'): |
2900 raise error.RepoError(_("There is no Mercurial repository here" | 2900 app = hgwebdir_mod.hgwebdir(opts['webdir_conf'], ui) |
2901 " (.hg not found)")) | 2901 elif repo is not None: |
2902 app = hgweb_mod.hgweb(hg.repository(repo.ui, repo.root)) | |
2903 else: | |
2904 raise error.RepoError(_("There is no Mercurial repository" | |
2905 " here (.hg not found)")) | |
2902 | 2906 |
2903 class service(object): | 2907 class service(object): |
2904 def init(self): | 2908 def init(self): |
2905 util.set_signal_handler() | 2909 util.set_signal_handler() |
2906 self.httpd = server.create_server(baseui, repo) | 2910 self.httpd = server.create_server(ui, app) |
2907 | 2911 |
2908 if opts['port'] and not ui.verbose: | 2912 if opts['port'] and not ui.verbose: |
2909 return | 2913 return |
2910 | 2914 |
2911 if self.httpd.prefix: | 2915 if self.httpd.prefix: |