Source

mercurial-crew-mq-inotify / profilingformat

# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits@gmail.com>
# Date 1238655690 -32400
# Node ID dc4ff050a7c353d8546844e96e8c37133348f980
# Parent  026bcd12a0adba249c2e1e1b43ccd4a8207c2e57
profiling: Adding a profiling.format config variable

Allows defining other output formats for profiling.

If an invalid format is given, output a warning and ignore it.
For now, only the standard 'text' value is supported.

diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt
--- a/doc/hgrc.5.txt
+++ b/doc/hgrc.5.txt
@@ -544,6 +544,13 @@
   In this section description, 'profiling data' stands for the raw data
   collected during profiling, while 'profiling report' stands for a
   statistical text report generated from the profiling data.
+  format;;
+    Profiling format.
+    Default: text.
+    text;;
+      Use lsprof for profiling, and generates a profiling report.
+      When saving to a file, it should be noted that only the report is saved,
+      and that the profiling data is not kept.
   output;;
     File path where profiling data or report should be saved.
     If the file exists, it is replaced.
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -379,6 +379,13 @@
             raise error.ParseError(cmd, _("invalid arguments"))
 
     if options['profile']:
+        format = ui.config('profiling', 'format', default='text')
+
+        if not format in ['text']:
+            ui.warn(_("unrecognized profiling format '%s'"
+                        " - Ignored\n") % format)
+            format = 'text'
+
         output = ui.config('profiling', 'output')
 
         if output:
diff --git a/tests/test-profile b/tests/test-profile
--- a/tests/test-profile
+++ b/tests/test-profile
@@ -15,4 +15,7 @@
         || echo --profile + output to file failed
     grep CallCount < ../out > /dev/null \
         || echo wrong --profile output when saving to a file
+
+    hg --profile --config profiling.format=text st 2>&1 \
+        | grep CallCount > /dev/null || echo --profile format=text failed
 fi