Mercurial > hg
changeset 2127:8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 25 Apr 2006 19:38:19 +0200 |
parents | 2e77f7852e82 |
children | 150208e0d94b |
files | mercurial/commands.py mercurial/hgweb.py |
diffstat | 2 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Apr 25 18:50:40 2006 +0200 +++ b/mercurial/commands.py Tue Apr 25 19:38:19 2006 +0200 @@ -2495,6 +2495,8 @@ """ if opts["stdio"]: + if repo is None: + raise hg.RepoError(_('no repo found')) fin, fout = sys.stdin, sys.stdout sys.stdout = sys.stderr @@ -2572,6 +2574,9 @@ if opts[o]: ui.setconfig("web", o, opts[o]) + if repo is None and not ui.config("web", "webdir_conf"): + raise hg.RepoError(_('no repo found')) + if opts['daemon'] and not opts['daemon_pipefds']: rfd, wfd = os.pipe() args = sys.argv[:] @@ -2583,7 +2588,7 @@ os._exit(0) try: - httpd = hgweb.create_server(repo) + httpd = hgweb.create_server(ui, repo) except socket.error, inst: raise util.Abort(_('cannot start server: ') + inst.args[1]) @@ -3202,7 +3207,7 @@ norepo = ("clone init version help debugancestor debugcomplete debugdata" " debugindex debugindexdot") -optionalrepo = ("paths debugconfig") +optionalrepo = ("paths serve debugconfig") def findpossible(cmd): """
--- a/mercurial/hgweb.py Tue Apr 25 18:50:40 2006 +0200 +++ b/mercurial/hgweb.py Tue Apr 25 19:38:19 2006 +0200 @@ -889,7 +889,7 @@ else: req.write(self.t("error")) -def create_server(repo): +def create_server(ui, repo): use_threads = True def openlog(opt, default): @@ -897,12 +897,12 @@ return open(opt, 'w') return default - address = repo.ui.config("web", "address", "") - port = int(repo.ui.config("web", "port", 8000)) - use_ipv6 = repo.ui.configbool("web", "ipv6") - webdir_conf = repo.ui.config("web", "webdir_conf") - accesslog = openlog(repo.ui.config("web", "accesslog", "-"), sys.stdout) - errorlog = openlog(repo.ui.config("web", "errorlog", "-"), sys.stderr) + address = ui.config("web", "address", "") + port = int(ui.config("web", "port", 8000)) + use_ipv6 = ui.configbool("web", "ipv6") + webdir_conf = ui.config("web", "webdir_conf") + accesslog = openlog(ui.config("web", "accesslog", "-"), sys.stdout) + errorlog = openlog(ui.config("web", "errorlog", "-"), sys.stderr) if use_threads: try: @@ -988,8 +988,10 @@ if webdir_conf: hgwebobj = hgwebdir(webdir_conf) + elif repo is not None: + hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot)) else: - hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot)) + raise hg.RepoError(_('no repo found')) hgwebobj.run(req)