stablerange: have the class behave as a tuple
If we want people to use a tuple, we should offer them a tuple. This should help
update most of the code iteratively.
--- a/hgext3rd/evolve/stablerange.py Wed Mar 22 05:44:39 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Wed Mar 22 05:15:49 2017 +0100
@@ -357,6 +357,15 @@
raise NotImplementedError()
return self.stablekey == other.stablekey
+ def __getitem__(self, idx):
+ """small helper function to prepare for the migration to tuple"""
+ if idx == 0:
+ return self.head
+ elif idx == 1:
+ return self.index
+ else:
+ raise IndexError(idx)
+
@util.propertycache
def _id(self):
return hash(self.stablekey)