# HG changeset patch # User Pierre-Yves David # Date 1490150980 -3600 # Node ID 318aba30dec354d79ab5148930b6a0da8d69c699 # Parent e2770faac2df6d348c9b48ca4fdaca84b4c8aa22 subranges: migrate handling of single element range This is the simplest case by far, so we start with that one. We still use the rich object as an argument, but we'll do our best to not relying on that. This is important for performance reason. diff -r e2770faac2df -r 318aba30dec3 hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 03:47:28 2017 +0100 +++ b/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 03:49:40 2017 +0100 @@ -604,8 +604,6 @@ cached = self._repo.stablerange.subranges(self._repo, self) if cached is not None: return cached - if len(self) == 1: - return [] step = _hlp2(self.depth) standard_start = 0 while standard_start < self.index and 0 < step: diff -r e2770faac2df -r 318aba30dec3 hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Wed Mar 22 03:47:28 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Wed Mar 22 03:49:40 2017 +0100 @@ -103,10 +103,19 @@ revdepth += len(cl.findmissingrevs(common=[anc], heads=[rev])) return revdepth + def rangelength(self, repo, rangeid): + headrev, index = rangeid.head, rangeid.index + return self.depthrev(repo, headrev) - index + def subranges(self, repo, rangeid): cached = self._subrangescache.get(rangeid) if cached is not None: return cached + if self.rangelength(repo, rangeid) == 1: + value = [] + self._subrangescache[rangeid] = value + return value + return None def setsubranges(self, rangeid, value): # XXX temporary cache setter as value computation are performed outside