##// 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 from mercurial.hgweb.hgwebdir_mod import hgwebdir
24 from mercurial.hgweb.hgwebdir_mod import hgwebdir
25 from mercurial.hgweb.request import wsgiapplication
25 from mercurial.hgweb.request import wsgiapplication
26 from mercurial import dispatch, ui
27 from flup.server.fcgi import WSGIServer
26 from flup.server.fcgi import WSGIServer
28
27
29 # The config file looks like this. You can have paths to individual
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 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
44 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
46 # or use a dictionary with entries like 'virtual/path': '/real/path'
45 # or use a dictionary with entries like 'virtual/path': '/real/path'
47
46
48 def web_app(ui):
47 def make_web_app():
49 return lambda: hgwebdir("hgweb.config", ui)
48 return hgwebdir("hgweb.config")
50
49
51 u = ui.ui(report_untrusted=False, interactive=False)
50 WSGIServer(wsgiapplication(make_web_app)).run()
52 dispatch.profiled(u, lambda: WSGIServer(wsgiapplication(web_app(u))).run())
@@ -403,17 +403,6 b' paths::'
403 Optional. Directory or URL to use when pushing if no destination
403 Optional. Directory or URL to use when pushing if no destination
404 is specified.
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 server::
406 server::
418 Controls generic server settings.
407 Controls generic server settings.
419 uncompressed;;
408 uncompressed;;
@@ -22,9 +22,7 b' cgitb.enable()'
22 #os.environ["HGENCODING"] = "UTF-8"
22 #os.environ["HGENCODING"] = "UTF-8"
23
23
24 from mercurial.hgweb.hgweb_mod import hgweb
24 from mercurial.hgweb.hgweb_mod import hgweb
25 from mercurial import dispatch, ui
26 import mercurial.hgweb.wsgicgi as wsgicgi
25 import mercurial.hgweb.wsgicgi as wsgicgi
27
26
28 u = ui.ui(report_untrusted=False, interactive=False)
27 application = hgweb("/path/to/repo", "repository name")
29 dispatch.profiled(u, lambda: wsgicgi.launch(hgweb("/path/to/repo",
28 wsgicgi.launch(application)
30 "repository name", u)))
@@ -22,7 +22,6 b' cgitb.enable()'
22 #os.environ["HGENCODING"] = "UTF-8"
22 #os.environ["HGENCODING"] = "UTF-8"
23
23
24 from mercurial.hgweb.hgwebdir_mod import hgwebdir
24 from mercurial.hgweb.hgwebdir_mod import hgwebdir
25 from mercurial import dispatch, ui
26 import mercurial.hgweb.wsgicgi as wsgicgi
25 import mercurial.hgweb.wsgicgi as wsgicgi
27
26
28 # The config file looks like this. You can have paths to individual
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 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
43 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
45 # or use a dictionary with entries like 'virtual/path': '/real/path'
44 # or use a dictionary with entries like 'virtual/path': '/real/path'
46
45
47 u = ui.ui(report_untrusted=False, interactive=False)
46 application = hgwebdir('hgweb.config')
48 dispatch.profiled(u, lambda: wsgicgi.launch(hgwebdir('hgweb.config', u)))
47 wsgicgi.launch(application)
@@ -373,17 +373,8 b' def _runcommand(ui, options, cmd, cmdfun'
373 if len(tb) != 2: # no
373 if len(tb) != 2: # no
374 raise
374 raise
375 raise ParseError(cmd, _("invalid arguments"))
375 raise ParseError(cmd, _("invalid arguments"))
376 return profiled(ui, checkargs, options)
377
376
378 def profiled(ui, func, options={}):
377 if options['profile']:
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':
387 import hotshot, hotshot.stats
378 import hotshot, hotshot.stats
388 prof = hotshot.Profile("hg.prof")
379 prof = hotshot.Profile("hg.prof")
389 try:
380 try:
@@ -399,11 +390,10 b' def profiled(ui, func, options={}):'
399 finally:
390 finally:
400 prof.close()
391 prof.close()
401 stats = hotshot.stats.load("hg.prof")
392 stats = hotshot.stats.load("hg.prof")
402 stats.stream = profile_fp()
403 stats.strip_dirs()
393 stats.strip_dirs()
404 stats.sort_stats('time', 'calls')
394 stats.sort_stats('time', 'calls')
405 stats.print_stats(40)
395 stats.print_stats(40)
406 elif options.get('lsprof') or ui.config('profile', 'enable') == 'lsprof':
396 elif options['lsprof']:
407 try:
397 try:
408 from mercurial import lsprof
398 from mercurial import lsprof
409 except ImportError:
399 except ImportError:
@@ -413,11 +403,11 b' def profiled(ui, func, options={}):'
413 p = lsprof.Profiler()
403 p = lsprof.Profiler()
414 p.enable(subcalls=True)
404 p.enable(subcalls=True)
415 try:
405 try:
416 return func()
406 return checkargs()
417 finally:
407 finally:
418 p.disable()
408 p.disable()
419 stats = lsprof.Stats(p.getstats())
409 stats = lsprof.Stats(p.getstats())
420 stats.sort()
410 stats.sort()
421 stats.pprint(top=10, file=profile_fp(), climit=5)
411 stats.pprint(top=10, file=sys.stderr, climit=5)
422 else:
412 else:
423 return func()
413 return checkargs()
@@ -79,10 +79,9 b' def revnavgen(pos, pagelen, limit, nodef'
79 return nav
79 return nav
80
80
81 class hgweb(object):
81 class hgweb(object):
82 def __init__(self, repo, name=None, parentui=None):
82 def __init__(self, repo, name=None):
83 if isinstance(repo, str):
83 if isinstance(repo, str):
84 parentui = (parentui or
84 parentui = ui.ui(report_untrusted=False, interactive=False)
85 ui.ui(report_untrusted=False, interactive=False))
86 self.repo = hg.repository(parentui, repo)
85 self.repo = hg.repository(parentui, repo)
87 else:
86 else:
88 self.repo = repo
87 self.repo = repo
General Comments 0
You need to be logged in to leave comments. Login now