Patchwork [1,of,2] status: fix default value of status struct

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 21, 2019, 2:13 p.m.
Message ID <c19643244c5c9952ff62.1574345629@mimosa>
Download mbox | patch
Permalink /patch/43391/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 21, 2019, 2:13 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1574344343 -32400
#      Thu Nov 21 22:52:23 2019 +0900
# Node ID c19643244c5c9952ff624663e5232c5071d568da
# Parent  835d415c5a17258e2cf11e9fcd650441690dfbd4
status: fix default value of status struct

The default argument isn't overloaded. Before, the default constructor would
create a struct having 7 list type objects.
Pulkit Goyal - Nov. 25, 2019, 3:13 p.m.
On Thu, Nov 21, 2019 at 5:47 PM Yuya Nishihara <yuya@tcha.org> wrote:
>
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1574344343 -32400
> #      Thu Nov 21 22:52:23 2019 +0900
> # Node ID c19643244c5c9952ff624663e5232c5071d568da
> # Parent  835d415c5a17258e2cf11e9fcd650441690dfbd4
> status: fix default value of status struct
>
> The default argument isn't overloaded. Before, the default constructor would
> create a struct having 7 list type objects.

Queued the series, many thanks!
>
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -70,13 +70,13 @@ class status(object):
>      relevant to the working copy.
>      '''
>
> -    modified = attr.ib(default=list)
> -    added = attr.ib(default=list)
> -    removed = attr.ib(default=list)
> -    deleted = attr.ib(default=list)
> -    unknown = attr.ib(default=list)
> -    ignored = attr.ib(default=list)
> -    clean = attr.ib(default=list)
> +    modified = attr.ib(default=attr.Factory(list))
> +    added = attr.ib(default=attr.Factory(list))
> +    removed = attr.ib(default=attr.Factory(list))
> +    deleted = attr.ib(default=attr.Factory(list))
> +    unknown = attr.ib(default=attr.Factory(list))
> +    ignored = attr.ib(default=attr.Factory(list))
> +    clean = attr.ib(default=attr.Factory(list))
>
>      def __iter__(self):
>          yield self.modified
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -70,13 +70,13 @@  class status(object):
     relevant to the working copy.
     '''
 
-    modified = attr.ib(default=list)
-    added = attr.ib(default=list)
-    removed = attr.ib(default=list)
-    deleted = attr.ib(default=list)
-    unknown = attr.ib(default=list)
-    ignored = attr.ib(default=list)
-    clean = attr.ib(default=list)
+    modified = attr.ib(default=attr.Factory(list))
+    added = attr.ib(default=attr.Factory(list))
+    removed = attr.ib(default=attr.Factory(list))
+    deleted = attr.ib(default=attr.Factory(list))
+    unknown = attr.ib(default=attr.Factory(list))
+    ignored = attr.ib(default=attr.Factory(list))
+    clean = attr.ib(default=attr.Factory(list))
 
     def __iter__(self):
         yield self.modified