]> git.madduck.net Git - etc/taskwarrior.git/blobdiff - tasklib/task.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Task: Make a dict.copy() for _original_data
[etc/taskwarrior.git] / tasklib / task.py
index 3860f8efd7b7309b409ee9fd0fbcfa5ac83e49ef..44c6965c1e3fdde7be836e48a4f8befb7f9a38c8 100644 (file)
@@ -29,7 +29,9 @@ class TaskResource(object):
 
     def _load_data(self, data):
         self._data = data
-        self._original_data = data
+        # We need to use a copy for original data, so that changes
+        # are not propagated
+        self._original_data = data.copy()
 
     def __getitem__(self, key):
         hydrate_func = getattr(self, 'deserialize_{0}'.format(key),
@@ -276,7 +278,10 @@ class Task(TaskResource):
             self._original_data.update(to_update)
         else:
             self._data = new_data
-            self._original_data = new_data
+            # We need to create a clone for original_data though
+            # Shallow copy is alright, since data dict uses only
+            # primitive data types
+            self._original_data = new_data.copy()
 
 
 class TaskFilter(object):