changeset 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 bf118f39afd7
children fc959d6ffb13
files mercurial/commands.py
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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: