Patchwork D9086: changing-files: move default constructor value to None

login
register
mail settings
Submitter phabricator
Date Sept. 26, 2020, 12:09 p.m.
Message ID <differential-rev-PHID-DREV-ppnh7ruoal2nak4i7vfz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47288/
State Superseded
Headers show

Comments

phabricator - Sept. 26, 2020, 12:09 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  According to Augie Fackler, using tuple as default value confuse PyType when
  actual values are passed at init time.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9086

AFFECTED FILES
  mercurial/metadata.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -40,15 +40,20 @@ 
     """
 
     def __init__(
-        self, touched=(), added=(), removed=(), p1_copies=(), p2_copies=(),
+        self,
+        touched=None,
+        added=None,
+        removed=None,
+        p1_copies=None,
+        p2_copies=None,
     ):
-        self._added = set(added)
-        self._removed = set(removed)
-        self._touched = set(touched)
+        self._added = set(() if added is None else added)
+        self._removed = set(() if removed is None else removed)
+        self._touched = set(() if touched is None else touched)
         self._touched.update(self._added)
         self._touched.update(self._removed)
-        self._p1_copies = dict(p1_copies)
-        self._p2_copies = dict(p2_copies)
+        self._p1_copies = dict(() if p1_copies is None else p1_copies)
+        self._p2_copies = dict(() if p2_copies is None else p2_copies)
 
     def __eq__(self, other):
         return (