diff mercurial/dispatch.py @ 6141:90e5c82a3859

Backed out changeset b913d3aacddc (see issue971/msg5317)
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 18 Feb 2008 19:20:22 +0100
parents b913d3aacddc
children 50a277e6ceae
line wrap: on
line diff
--- a/mercurial/dispatch.py	Fri Feb 01 13:09:45 2008 -0800
+++ b/mercurial/dispatch.py	Mon Feb 18 19:20:22 2008 +0100
@@ -373,17 +373,8 @@
             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 @@
         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 @@
         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()