mercurial/commands.py
changeset 1832 7a58bf789965
parent 1823 adef8661c8f9
child 1833 fc959d6ffb13
--- 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: