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

Mads Kiilerich mads at kiilerich.com
Sat Oct 11 20:00:16 CDT 2014


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.

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

/Mads


More information about the Mercurial-devel mailing list