[PATCH 01 of 13] ui: add ui.write() output labeling API

Steve Borho steve at borho.org
Fri Apr 2 14:09:34 CDT 2010


On Wed, Mar 31, 2010 at 3:08 PM, Brodie Rao <dackze at gmail.com> wrote:
> On Mar 31, 2010, at 4:10 PM, Gilles Moris wrote:
>
>> On Wednesday 31 March 2010 07:09:29 pm Brodie Rao wrote:
>>> 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?
>>>
>>
>> Has the option of deriving the ui class in color.py been already considered ?
>> Could it be an option ?
>> This would avoid making _buffer public.
>
> From #mercurial:
>
> 12:56 < mpm> I think we should keep the _ on buffers.
> 12:57 < mpm> It's not like C++, where privacy is enforced, it's a hint to the unsuspecting that you shouldn't be poking at it.
> 12:57 < mpm> And the average user of ui really shouldn't be.
> 12:57 < mpm> Only things that effectively 'friends' (in C++ speak) should look at buffers.
> 12:58 < mpm> Does that make sense?
> 12:58 < brodie> i was thinking it would be clearer for people writing wrappers to do this, but i don't have any strong feelings about it either way
> 12:59 < mpm> '_' says 'this is not part of the API', people writing wrappers are not writing to the API.
> 12:59 < mpm> They're instead changing the implementation.
> 13:00 < brodie> that makes sense
>
> I've changed it back to _buffers.
>
> Also, I was using a subclass initially, but using extensions.wrapfunction() on instance methods doesn't play well with changing __class__ on existing instances. The orig() function the wrapper receives will always point to the method of the original class.

Hi Brodie,

Could you patchbomb the final ui patch with _buffers returned to their
original form?

--
Steve Borho


More information about the Mercurial-devel mailing list