# HG changeset patch # User Pierre-Yves David # Date 1490351276 -3600 # Node ID eadb1c69e3505f64e10ef159701d5fc7544123e6 # Parent 16a5a37ced62d540b1c99f8581c9040bcb5b413c stablerange: support loading the cache iteratively We record how far we loaded so that we can resume from this point. diff -r 16a5a37ced62 -r eadb1c69e350 hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Fri Mar 24 11:20:42 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Fri Mar 24 11:27:56 2017 +0100 @@ -225,6 +225,9 @@ class stablerange(object): def __init__(self): + # The point up to which we have data in cache + self._tiprev = None + self._tipnode = None # cache the 'depth' of a changeset, the size of '::rev' self._depthcache = {} # cache the standard stable subranges or a range @@ -249,6 +252,7 @@ def warmup(self, repo, upto=None): """warm the cache up""" repo = repo.unfiltered() + cl = repo.changelog # subrange should be warmed from head to range to be able to benefit # from revsfromrange cache. otherwise each merge will trigger its own # stablesort. @@ -256,12 +260,17 @@ # we use the revnumber as an approximation for depth ui = repo.ui - if upto: - revs = repo.changelog.revs(stop=upto) + if upto is None: + upto = len(cl) - 1 + if self._tiprev is None: + revs = cl.revs(stop=upto) nbrevs = upto + 1 else: - revs = list(repo.changelog.revs()) - nbrevs = len(repo.changelog) + assert cl.node(self._tiprev) == self._tipnode + if upto <= self._tiprev: + return + revs = cl.revs(start=self._tiprev + 1, stop=upto) + nbrevs = upto - self._tiprev rangeheap = [] for idx, r in enumerate(revs): if not idx % 1000: @@ -292,6 +301,9 @@ heappush(rangeheap, (-sub[0], sub)) ui.progress(_("filling stablerange cache"), None, total=nbrevs) + self._tiprev = upto + self._tipnode = cl.node(upto) + def depthrev(self, repo, rev): repo = repo.unfiltered() cl = repo.changelog