mercurial/dispatch.py
changeset 8024 9a1b86cfd29e
parent 8023 fd9debb3ea1b
child 8136 6b5522cb2ad2
--- a/mercurial/dispatch.py	Thu Apr 02 16:01:30 2009 +0900
+++ b/mercurial/dispatch.py	Wed Apr 08 14:20:57 2009 +0200
@@ -381,7 +381,7 @@
     if options['profile']:
         format = ui.config('profiling', 'format', default='text')
 
-        if not format in ['text']:
+        if not format in ['text', 'kcachegrind']:
             ui.warn(_("unrecognized profiling format '%s'"
                         " - Ignored\n") % format)
             format = 'text'
@@ -407,9 +407,16 @@
             return checkargs()
         finally:
             p.disable()
-            stats = lsprof.Stats(p.getstats())
-            stats.sort()
-            stats.pprint(top=10, file=ostream, climit=5)
+
+            if format == 'kcachegrind':
+                import lsprofcalltree
+                calltree = lsprofcalltree.KCacheGrind(p)
+                calltree.output(ostream)
+            else:
+                # format == 'text'
+                stats = lsprof.Stats(p.getstats())
+                stats.sort()
+                stats.pprint(top=10, file=ostream, climit=5)
 
             if output:
                 ostream.close()