manifest: make copy logic local to copy()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 23 Feb 2015 13:41:02 -0800
changeset 24146 dd8c891dd09a
parent 24145 28af978c8f13
child 24147 ba4fcd80079d
manifest: make copy logic local to copy() The optional arguments to the manfifestdict constructor are only used by copy(), so assign the fields from that method instead so it's clear that the arguments are not used for anything else.
mercurial/manifest.py
--- a/mercurial/manifest.py	Sat Feb 21 00:40:18 2015 -0500
+++ b/mercurial/manifest.py	Mon Feb 23 13:41:02 2015 -0800
@@ -10,13 +10,8 @@
 import array, struct
 
 class manifestdict(dict):
-    def __init__(self, mapping=None, flags=None):
-        if mapping is None:
-            mapping = {}
-        if flags is None:
-            flags = {}
-        dict.__init__(self, mapping)
-        self._flags = flags
+    def __init__(self):
+        self._flags = {}
     def __setitem__(self, k, v):
         assert v is not None
         dict.__setitem__(self, k, v)
@@ -26,7 +21,10 @@
         """Set the flags (symlink, executable) for path f."""
         self._flags[f] = flags
     def copy(self):
-        return manifestdict(self, dict.copy(self._flags))
+        copy = manifestdict()
+        dict.__init__(copy, self)
+        copy._flags = dict.copy(self._flags)
+        return copy
     def intersectfiles(self, files):
         '''make a new manifestdict with the intersection of self with files