[master 4/4] Make an __copy__ method for FS that creates new Task objects.

mulkieran installerbot-noreply at redhat.com
Wed Jun 24 17:08:02 UTC 2015


From: mulhern <amulhern at redhat.com>

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/formats/fs.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 79bb68c..e698db0 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -147,6 +147,16 @@ def _createTaskObjects(self):
         self._minsize = self._minsizeClass(self)
         self._sizeinfo = self._sizeinfoClass(self)
 
+    def __copy__(self):
+        # Constructs new task objects for the copied FS.
+        # This ensures that each task object refers back to the newly
+        # constructed object, result, rather than self.
+        cls = self.__class__
+        result = cls.__new__(cls)
+        result.__dict__.update(self.__dict__)
+        result._createTaskObjects()
+        return result
+
     def __repr__(self):
         s = DeviceFormat.__repr__(self)
         s += ("  mountpoint = %(mountpoint)s  mountopts = %(mountopts)s\n"


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/48fef007615329600abf2fd8871b9e0affb5369e


More information about the anaconda-patches mailing list