generate profile even when exception raised.
otherwise, is not possible to profile hg serve.
--- a/mercurial/commands.py Fri Mar 03 09:40:18 2006 -0800
+++ b/mercurial/commands.py Fri Mar 03 13:11:25 2006 -0800
@@ -2862,13 +2862,21 @@
if options['profile']:
import hotshot, hotshot.stats
prof = hotshot.Profile("hg.prof")
- r = prof.runcall(d)
- prof.close()
- stats = hotshot.stats.load("hg.prof")
- stats.strip_dirs()
- stats.sort_stats('time', 'calls')
- stats.print_stats(40)
- return r
+ try:
+ try:
+ return prof.runcall(d)
+ except:
+ try:
+ u.warn(_('exception raised - generating profile '
+ 'anyway\n'))
+ except:
+ pass
+ finally:
+ prof.close()
+ stats = hotshot.stats.load("hg.prof")
+ stats.strip_dirs()
+ stats.sort_stats('time', 'calls')
+ stats.print_stats(40)
else:
return d()
except: