# HG changeset patch # User Boris Feld # Date 1496225364 -7200 # Node ID 537058b433efd0e2d4316a675403fb0125c30b1f # Parent 8ac4ceac5d96e1fb50b6a775ae99de086dfd91d9 compat: fix stablerange for mercurial 3.9 Lrudict.get change of api between mercurial 3.9 and mercurial 4.2. Bypass this limitation by using lrudict.__getitem__ and catch the KeyError directly. diff -r 8ac4ceac5d96 -r 537058b433ef hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Tue May 30 22:09:28 2017 +0200 +++ b/hgext3rd/evolve/stablerange.py Wed May 31 12:09:24 2017 +0200 @@ -394,7 +394,14 @@ # note: In the general case we can just walk down and then request # data about the merge. But I'm not sure this function will be even # call for the general case. - allrevs = self._stablesortcache.get(headrev) + + # Lrudict.get in hg-3.9 returns the lrunode instead of the + # value, use __getitem__ instead and catch the exception directly + try: + allrevs = self._stablesortcache[headrev] + except KeyError: + allrevs = None + if allrevs is None: allrevs = self._getrevsfrommerge(repo, headrev) if allrevs is None: @@ -443,8 +450,11 @@ self._stablesortprepared[merge] = (sortedrevs, len(sortedrevs)) def _getrevsfrommerge(self, repo, merge): - prepared = self._stablesortprepared.get(merge) - if prepared is None: + # Lrudict.get in hg-3.9 returns the lrunode instead of the + # value, use __getitem__ instead and catch the exception directly + try: + prepared = self._stablesortprepared[merge] + except KeyError: return None mergedepth = self.depthrev(repo, merge)