profile: expand PID in output file name
authorBryan O'Sullivan <bos@serpentine.com>
Fri, 01 Feb 2008 13:31:46 -0800
changeset 5997 637d4c089834
parent 5996 3f9ce63da18c
child 5998 5d91f6e6f841
profile: expand PID in output file name
doc/hgrc.5.txt
mercurial/dispatch.py
--- a/doc/hgrc.5.txt	Fri Feb 01 13:11:03 2008 -0800
+++ b/doc/hgrc.5.txt	Fri Feb 01 13:31:46 2008 -0800
@@ -412,7 +412,10 @@
     "hotshot" is deprecated, and produces less reliable results.
     Default is no profiling.
   output;;
-    The name of a file to write profiling data to.  Default is stderr.
+    The name of a file to write profiling data to.  Each occurrence of
+    "%%p" will be replaced with the current process ID (the repeated
+    "%" protects against the config parser's string interpolator).
+    Default output is to stderr.
   
 server::
   Controls generic server settings.
--- a/mercurial/dispatch.py	Fri Feb 01 13:11:03 2008 -0800
+++ b/mercurial/dispatch.py	Fri Feb 01 13:31:46 2008 -0800
@@ -379,7 +379,8 @@
     def profile_fp():
         outfile = ui.config('profile', 'output', untrusted=True)
         if outfile:
-            return open(outfile, 'w')
+            pid = str(os.getpid())
+            return open(outfile.replace('%p', pid), 'w')
         else:
             return sys.stderr