]> git.madduck.net Git - etc/taskwarrior.git/commitdiff

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 uuid equality more restrictive for unsaved tasks
authorTomas Babej <tomasbabej@gmail.com>
Sun, 28 Dec 2014 02:15:47 +0000 (03:15 +0100)
committerTomas Babej <tomasbabej@gmail.com>
Sun, 28 Dec 2014 02:15:47 +0000 (03:15 +0100)
tasklib/task.py

index 8fe1e1b47df278c8d58e8692a266dbc3215ac6c1..1fa3faa675a5022057f70261ddba8f5c1e87fc4b 100644 (file)
@@ -122,10 +122,21 @@ class Task(TaskResource):
         return self['description']
 
     def __eq__(self, other):
-        return self['uuid'] == other['uuid']
+        if self['uuid'] and other['uuid']:
+            # For saved Tasks, just define equality by equality of uuids
+            return self['uuid'] == other['uuid']
+        else:
+            # If the tasks are not saved, compare the actual instances
+            return id(self) == id(other)
+
 
     def __hash__(self):
-        return self['uuid'].__hash__()
+        if self['uuid']:
+            # For saved Tasks, just define equality by equality of uuids
+            return self['uuid'].__hash__()
+        else:
+            # If the tasks are not saved, return hash of instance id
+            return id(self).__hash__()
 
     @property
     def _modified_fields(self):