Skip to content

Commit

Permalink
Make an __copy__ method for FS that creates new Task objects.
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Jun 24, 2015
1 parent 6fcb922 commit 48fef00
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blivet/formats/fs.py
Expand Up @@ -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"
Expand Down

0 comments on commit 48fef00

Please sign in to comment.