stablerange: drop "key" and "id" logic form the class
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 22 Mar 2017 19:30:23 +0100
changeset 2181 eea1fdeb1eb3
parent 2180 7570e0683460
child 2182 884f6309eae7
stablerange: drop "key" and "id" logic form the class We can restrict to the bare minimun for equality and hashing now.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Wed Mar 22 19:28:14 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Wed Mar 22 19:30:23 2017 +0100
@@ -352,12 +352,12 @@
         assert index < depth, (head, index, depth, revs)
 
     def __hash__(self):
-        return self._id
+        return hash((self._head, self._index))
 
     def __eq__(self, other):
         if type(self) != type(other):
             raise NotImplementedError()
-        return self._stablekey == other._stablekey
+        return (self._head, self._index) == (other._head, other._index)
 
     def __getitem__(self, idx):
         """small helper function to prepare for the migration to tuple"""
@@ -369,14 +369,6 @@
             raise IndexError(idx)
 
     @util.propertycache
-    def _id(self):
-        return hash(self._stablekey)
-
-    @util.propertycache
-    def _stablekey(self):
-        return (self[0], self[1])
-
-    @util.propertycache
     def _revs(self):
         length = self._repo.stablerange.rangelength(self._repo, self)
         r = stablesort(self._repo, [self[0]])[self[1]:]