[PATCH 01 of 13] ui: add ui.write() output labeling API
Brodie Rao
dackze at gmail.com
Wed Mar 31 12:09:29 CDT 2010
On Mar 31, 2010, at 12:33 PM, Matt Mackall wrote:
> On Wed, 2010-03-31 at 10:00 -0500, Brodie Rao wrote:
>> class ui(object):
>> def __init__(self, src=None):
>> - self._buffers = []
>> + self.buffers = []
>
> Uh, have we decided that buffers is now a public member?
Anyone wrapping write/write_err and popbuffer() will also need access to buffers. You can see this usage in the patch against hgext/color.py. Do you think this is a bad idea?
I had an earlier implementation where ui.write(), ui.popbuffer(), etc. in mercurial/ui.py called out to ui.label() directly, and you only had to wrap ui.label() to handle labels, but I think we decided at the sprint that there should be as little of a performance hit as possible, so making sure ui.label() is called is now up to the wrappers.
>> - def status(self, *msg):
>> + def status(self, *msg, **opts):
>> if not self.quiet:
>> - self.write(*msg)
>> - def warn(self, *msg):
>> - self.write_err(*msg)
>> - def note(self, *msg):
>> + opts['label'] = opts.get('label', '') + ' ui.status'
>> + self.write(*msg, **opts)
>
> Interesting. I guess that's ok, but I didn't see any mention of it.
I can add doc strings to each method that mention what labels they add.
More information about the Mercurial-devel
mailing list