diff --git a/mercurial/hgweb.py b/mercurial/hgweb.py --- a/mercurial/hgweb.py +++ b/mercurial/hgweb.py @@ -889,7 +889,7 @@ class hgweb(object): 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 @@ def create_server(repo): 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 @@ def create_server(repo): 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)