Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 1832:7a58bf789965
generate profile even when exception raised.
otherwise, is not possible to profile hg serve.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 03 Mar 2006 13:11:25 -0800 |
parents | adef8661c8f9 |
children | fc959d6ffb13 |
comparison
equal
deleted
inserted
replaced
1831:bf118f39afd7 | 1832:7a58bf789965 |
---|---|
2860 d = lambda: func(u, *args, **cmdoptions) | 2860 d = lambda: func(u, *args, **cmdoptions) |
2861 | 2861 |
2862 if options['profile']: | 2862 if options['profile']: |
2863 import hotshot, hotshot.stats | 2863 import hotshot, hotshot.stats |
2864 prof = hotshot.Profile("hg.prof") | 2864 prof = hotshot.Profile("hg.prof") |
2865 r = prof.runcall(d) | 2865 try: |
2866 prof.close() | 2866 try: |
2867 stats = hotshot.stats.load("hg.prof") | 2867 return prof.runcall(d) |
2868 stats.strip_dirs() | 2868 except: |
2869 stats.sort_stats('time', 'calls') | 2869 try: |
2870 stats.print_stats(40) | 2870 u.warn(_('exception raised - generating profile ' |
2871 return r | 2871 'anyway\n')) |
2872 except: | |
2873 pass | |
2874 finally: | |
2875 prof.close() | |
2876 stats = hotshot.stats.load("hg.prof") | |
2877 stats.strip_dirs() | |
2878 stats.sort_stats('time', 'calls') | |
2879 stats.print_stats(40) | |
2872 else: | 2880 else: |
2873 return d() | 2881 return d() |
2874 except: | 2882 except: |
2875 # enter the debugger when we hit an exception | 2883 # enter the debugger when we hit an exception |
2876 if options['debugger']: | 2884 if options['debugger']: |