[PATCH V2] profiling: allow logging profile to the blackbox

Simon King simon at simonking.org.uk
Wed Sep 9 15:05:34 CDT 2015


> On 9 Sep 2015, at 19:04, Matt Mackall <mpm at selenic.com> wrote:
> 
> On Wed, 2015-09-09 at 16:18 +0000, Durham Goode wrote:
>>>> +                if output == 'blackbox':
>>>> +                    val = "Profile:\n%s" % fp.getvalue()
>>>> +                    # ui.log treats the input as a format string,
>>>> +                    # so we need to escape any % signs.
>>> 
>>> Oh, I see. This is actually documented only in blackbox.py - should we
>>> document that on ui.log itself as part of the API contract?
>>> 
>>> (I'm happy to do that, it was just surprising.)
>> 
>> That sounds reasonable.  For some reason I thought this was the
>> behavior for all of the ui.status/warn/note commands, but I guess I
>> was wrong.  I think we did it this way because most users don't have
>> the blackbox or any ui.log extensions enabled, so this avoids them
>> having to do the string formatting.
> 
> Right, it's a tiny optimization.

Perhaps it would be better to write:

  ui.log('profile', 'Profile:\n%s', fp.getvalue())

Simon


More information about the Mercurial-devel mailing list