upgrade: implement equality for 'improvement' object
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 10 Apr 2017 23:10:03 +0200
changeset 31902 6557f0d4ab8e
parent 31901 9bdedb050d8d
child 31903 fa1088de2119
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.
mercurial/upgrade.py
--- 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)