# HG changeset patch # User Thomas Arendsen Hein # Date 2008-02-18 18:20:22 # Node ID 90e5c82a3859f1c287d89e729deb3b8436d85ed5 # Parent b913d3aacddcec52732381839a0987719c39d217 Backed out changeset b913d3aacddc (see issue971/msg5317) diff --git a/contrib/hgwebdir.fcgi b/contrib/hgwebdir.fcgi --- a/contrib/hgwebdir.fcgi +++ b/contrib/hgwebdir.fcgi @@ -23,7 +23,6 @@ cgitb.enable() from mercurial.hgweb.hgwebdir_mod import hgwebdir from mercurial.hgweb.request import wsgiapplication -from mercurial import dispatch, ui from flup.server.fcgi import WSGIServer # The config file looks like this. You can have paths to individual @@ -45,8 +44,7 @@ from flup.server.fcgi import WSGIServer # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples # or use a dictionary with entries like 'virtual/path': '/real/path' -def web_app(ui): - return lambda: hgwebdir("hgweb.config", ui) +def make_web_app(): + return hgwebdir("hgweb.config") -u = ui.ui(report_untrusted=False, interactive=False) -dispatch.profiled(u, lambda: WSGIServer(wsgiapplication(web_app(u))).run()) +WSGIServer(wsgiapplication(make_web_app)).run() diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -403,17 +403,6 @@ paths:: Optional. Directory or URL to use when pushing if no destination is specified. -profile:: - Configuration of profiling options, for in-depth performance - analysis. Mostly useful to developers. - enable;; - Enable a particular profiling mode. Useful for profiling - server-side processes. "lsprof" enables modern profiling. - "hotshot" is deprecated, and produces less reliable results. - Default is no profiling. - output;; - The name of a file to write profiling data to. Default is stderr. - server:: Controls generic server settings. uncompressed;; diff --git a/hgweb.cgi b/hgweb.cgi --- a/hgweb.cgi +++ b/hgweb.cgi @@ -22,9 +22,7 @@ cgitb.enable() #os.environ["HGENCODING"] = "UTF-8" from mercurial.hgweb.hgweb_mod import hgweb -from mercurial import dispatch, ui import mercurial.hgweb.wsgicgi as wsgicgi -u = ui.ui(report_untrusted=False, interactive=False) -dispatch.profiled(u, lambda: wsgicgi.launch(hgweb("/path/to/repo", - "repository name", u))) +application = hgweb("/path/to/repo", "repository name") +wsgicgi.launch(application) diff --git a/hgwebdir.cgi b/hgwebdir.cgi --- a/hgwebdir.cgi +++ b/hgwebdir.cgi @@ -22,7 +22,6 @@ cgitb.enable() #os.environ["HGENCODING"] = "UTF-8" from mercurial.hgweb.hgwebdir_mod import hgwebdir -from mercurial import dispatch, ui import mercurial.hgweb.wsgicgi as wsgicgi # The config file looks like this. You can have paths to individual @@ -44,5 +43,5 @@ import mercurial.hgweb.wsgicgi as wsgicg # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples # or use a dictionary with entries like 'virtual/path': '/real/path' -u = ui.ui(report_untrusted=False, interactive=False) -dispatch.profiled(u, lambda: wsgicgi.launch(hgwebdir('hgweb.config', u))) +application = hgwebdir('hgweb.config') +wsgicgi.launch(application) diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -373,17 +373,8 @@ def _runcommand(ui, options, cmd, cmdfun if len(tb) != 2: # no raise raise ParseError(cmd, _("invalid arguments")) - return profiled(ui, checkargs, options) -def profiled(ui, func, options={}): - def profile_fp(): - outfile = ui.config('profile', 'output', untrusted=True) - if outfile: - return open(outfile, 'w') - else: - return sys.stderr - - if options.get('profile') or ui.config('profile', 'enable') == 'hotshot': + if options['profile']: import hotshot, hotshot.stats prof = hotshot.Profile("hg.prof") try: @@ -399,11 +390,10 @@ def profiled(ui, func, options={}): finally: prof.close() stats = hotshot.stats.load("hg.prof") - stats.stream = profile_fp() stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(40) - elif options.get('lsprof') or ui.config('profile', 'enable') == 'lsprof': + elif options['lsprof']: try: from mercurial import lsprof except ImportError: @@ -413,11 +403,11 @@ def profiled(ui, func, options={}): p = lsprof.Profiler() p.enable(subcalls=True) try: - return func() + return checkargs() finally: p.disable() stats = lsprof.Stats(p.getstats()) stats.sort() - stats.pprint(top=10, file=profile_fp(), climit=5) + stats.pprint(top=10, file=sys.stderr, climit=5) else: - return func() + return checkargs() diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -79,10 +79,9 @@ def revnavgen(pos, pagelen, limit, nodef return nav class hgweb(object): - def __init__(self, repo, name=None, parentui=None): + def __init__(self, repo, name=None): if isinstance(repo, str): - parentui = (parentui or - ui.ui(report_untrusted=False, interactive=False)) + parentui = ui.ui(report_untrusted=False, interactive=False) self.repo = hg.repository(parentui, repo) else: self.repo = repo