changelog: use a Factory for default value for files
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 02 Oct 2017 11:03:53 +0100
changeset 34442 50474f0b3f1b
parent 34441 7ed0750c71a1
child 34443 73d8a5283f87
changelog: use a Factory for default value for files The default value is compiled into the generated type. This means that default values are shared between instances. For immutable types like bool, str, int, and tuple, this is fine. But for mutable types like list and dict, we need to use attr.Factory() to instantiate a new instance of the default for each object. Differential Revision: https://phab.mercurial-scm.org/D901
mercurial/changelog.py
--- a/mercurial/changelog.py	Mon Oct 02 19:28:41 2017 +0100
+++ b/mercurial/changelog.py	Mon Oct 02 11:03:53 2017 +0100
@@ -151,7 +151,7 @@
     manifest = attr.ib(default=nullid)
     user = attr.ib(default='')
     date = attr.ib(default=(0, 0))
-    files = attr.ib(default=[])
+    files = attr.ib(default=attr.Factory(list))
     description = attr.ib(default='')
 
 class changelogrevision(object):