[PATCH 03 of 16 V3] dirstate: create class for status lists

Martin von Zweigbergk martinvonz at gmail.com
Sun Oct 12 05:10:29 UTC 2014


On Sat, Oct 11, 2014 at 6:00 PM, Mads Kiilerich <mads at kiilerich.com> wrote:
> 1+2 LGTM, but
>
> On 10/11/2014 12:20 AM, Martin von Zweigbergk wrote:
>>
>> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
>> --- a/mercurial/dirstate.py
>> +++ b/mercurial/dirstate.py
>> @@ -26,6 +26,51 @@
>>       def join(self, obj, fname):
>>           return obj._join(fname)
>>   +class status(tuple):
>> +    '''Named tuple with a list of files per status. The 'deleted',
>> 'unknown'
>> +       and 'ignored' properties are only relevant to the working copy.
>> +    '''
>> +
>> +    __slots__ = ()
>> +
>> +    def __new__(cls, modified=None, added=None, removed=None,
>> deleted=None,
>> +                unknown=None, ignored=None, clean=None):
>> +        return tuple.__new__(cls, (modified or [], added or [], removed
>> or [],
>> +                                   deleted or [], unknown or [], ignored
>> or [],
>> +                                   clean or []))
>
>
> I would expect:
> l = []
> s = status(l)
> l.append(7)
> assert s.modified == [7]
>
> The fallback to a new empty list should only be applied if the value is None
> - not for other false values.

Ah, of course. Sorry about that.

> For now, please just make the parameters mandatory. A later follow-up patch
> can always make them optional ... if we can be bothered ;-)

Will do. V4 coming up



More information about the Mercurial-devel mailing list