changeset 31902:6557f0d4ab8e

upgrade: implement equality for 'improvement' object Through the code, we use a mix of 'improvement' object and string. Having a single type would be simpler. For this we need the object to be comparable.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 10 Apr 2017 23:10:03 +0200
parents 9bdedb050d8d
children fa1088de2119
files mercurial/upgrade.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/upgrade.py	Mon Apr 10 22:15:17 2017 +0200
+++ b/mercurial/upgrade.py	Mon Apr 10 23:10:03 2017 +0200
@@ -138,6 +138,12 @@
         for k, v in kwargs.items():
             setattr(self, k, v)
 
+    def __eq__(self, other):
+        if not isinstance(other, improvement):
+            # This is what python tell use to do
+            return NotImplemented
+        return self.name == other.name
+
 def finddeficiencies(repo):
     """returns a list of deficiencies that the repo suffer from"""
     newreporeqs = localrepo.newreporequirements(repo)