# HG changeset patch # User Pierre-Yves David # Date 1490156149 -3600 # Node ID 647e222cd4ab59ee93d3efc3fbfbb5d3e31532a9 # Parent 90f8f100dd58fe4cd0fc8d7041b95bf8ee88c661 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. diff -r 90f8f100dd58 -r 647e222cd4ab hgext3rd/evolve/stablerange.py --- 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)