##// END OF EJS Templates
Backed out changeset b913d3aacddc (see issue971/msg5317)
Thomas Arendsen Hein -
r6141:90e5c82a default
parent child Browse files
Show More
@@ -23,7 +23,6 b' cgitb.enable()'
23 23
24 24 from mercurial.hgweb.hgwebdir_mod import hgwebdir
25 25 from mercurial.hgweb.request import wsgiapplication
26 from mercurial import dispatch, ui
27 26 from flup.server.fcgi import WSGIServer
28 27
29 28 # The config file looks like this. You can have paths to individual
@@ -45,8 +44,7 b' from flup.server.fcgi import WSGIServer'
45 44 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
46 45 # or use a dictionary with entries like 'virtual/path': '/real/path'
47 46
48 def web_app(ui):
49 return lambda: hgwebdir("hgweb.config", ui)
47 def make_web_app():
48 return hgwebdir("hgweb.config")
50 49
51 u = ui.ui(report_untrusted=False, interactive=False)
52 dispatch.profiled(u, lambda: WSGIServer(wsgiapplication(web_app(u))).run())
50 WSGIServer(wsgiapplication(make_web_app)).run()
@@ -403,17 +403,6 b' paths::'
403 403 Optional. Directory or URL to use when pushing if no destination
404 404 is specified.
405 405
406 profile::
407 Configuration of profiling options, for in-depth performance
408 analysis. Mostly useful to developers.
409 enable;;
410 Enable a particular profiling mode. Useful for profiling
411 server-side processes. "lsprof" enables modern profiling.
412 "hotshot" is deprecated, and produces less reliable results.
413 Default is no profiling.
414 output;;
415 The name of a file to write profiling data to. Default is stderr.
416
417 406 server::
418 407 Controls generic server settings.
419 408 uncompressed;;
@@ -22,9 +22,7 b' cgitb.enable()'
22 22 #os.environ["HGENCODING"] = "UTF-8"
23 23
24 24 from mercurial.hgweb.hgweb_mod import hgweb
25 from mercurial import dispatch, ui
26 25 import mercurial.hgweb.wsgicgi as wsgicgi
27 26
28 u = ui.ui(report_untrusted=False, interactive=False)
29 dispatch.profiled(u, lambda: wsgicgi.launch(hgweb("/path/to/repo",
30 "repository name", u)))
27 application = hgweb("/path/to/repo", "repository name")
28 wsgicgi.launch(application)
@@ -22,7 +22,6 b' cgitb.enable()'
22 22 #os.environ["HGENCODING"] = "UTF-8"
23 23
24 24 from mercurial.hgweb.hgwebdir_mod import hgwebdir
25 from mercurial import dispatch, ui
26 25 import mercurial.hgweb.wsgicgi as wsgicgi
27 26
28 27 # The config file looks like this. You can have paths to individual
@@ -44,5 +43,5 b' import mercurial.hgweb.wsgicgi as wsgicg'
44 43 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
45 44 # or use a dictionary with entries like 'virtual/path': '/real/path'
46 45
47 u = ui.ui(report_untrusted=False, interactive=False)
48 dispatch.profiled(u, lambda: wsgicgi.launch(hgwebdir('hgweb.config', u)))
46 application = hgwebdir('hgweb.config')
47 wsgicgi.launch(application)
@@ -373,17 +373,8 b' def _runcommand(ui, options, cmd, cmdfun'
373 373 if len(tb) != 2: # no
374 374 raise
375 375 raise ParseError(cmd, _("invalid arguments"))
376 return profiled(ui, checkargs, options)
377 376
378 def profiled(ui, func, options={}):
379 def profile_fp():
380 outfile = ui.config('profile', 'output', untrusted=True)
381 if outfile:
382 return open(outfile, 'w')
383 else:
384 return sys.stderr
385
386 if options.get('profile') or ui.config('profile', 'enable') == 'hotshot':
377 if options['profile']:
387 378 import hotshot, hotshot.stats
388 379 prof = hotshot.Profile("hg.prof")
389 380 try:
@@ -399,11 +390,10 b' def profiled(ui, func, options={}):'
399 390 finally:
400 391 prof.close()
401 392 stats = hotshot.stats.load("hg.prof")
402 stats.stream = profile_fp()
403 393 stats.strip_dirs()
404 394 stats.sort_stats('time', 'calls')
405 395 stats.print_stats(40)
406 elif options.get('lsprof') or ui.config('profile', 'enable') == 'lsprof':
396 elif options['lsprof']:
407 397 try:
408 398 from mercurial import lsprof
409 399 except ImportError:
@@ -413,11 +403,11 b' def profiled(ui, func, options={}):'
413 403 p = lsprof.Profiler()
414 404 p.enable(subcalls=True)
415 405 try:
416 return func()
406 return checkargs()
417 407 finally:
418 408 p.disable()
419 409 stats = lsprof.Stats(p.getstats())
420 410 stats.sort()
421 stats.pprint(top=10, file=profile_fp(), climit=5)
411 stats.pprint(top=10, file=sys.stderr, climit=5)
422 412 else:
423 return func()
413 return checkargs()
@@ -79,10 +79,9 b' def revnavgen(pos, pagelen, limit, nodef'
79 79 return nav
80 80
81 81 class hgweb(object):
82 def __init__(self, repo, name=None, parentui=None):
82 def __init__(self, repo, name=None):
83 83 if isinstance(repo, str):
84 parentui = (parentui or
85 ui.ui(report_untrusted=False, interactive=False))
84 parentui = ui.ui(report_untrusted=False, interactive=False)
86 85 self.repo = hg.repository(parentui, repo)
87 86 else:
88 87 self.repo = repo
General Comments 0
You need to be logged in to leave comments. Login now