stablesort: warm jump cache more efficiently
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 10 Dec 2017 03:49:48 +0100
changeset 3326 8ebd31af1452
parent 3325 83d2a2f3dc8f
child 3327 0abc8fb7f49f
stablesort: warm jump cache more efficiently We no longer for a full depth iteration for all request: - we exit early for non-merge, - for merge, we only iterate over the exclusive area.
hgext3rd/evolve/stablesort.py
--- a/hgext3rd/evolve/stablesort.py	Sun Dec 10 03:39:56 2017 +0100
+++ b/hgext3rd/evolve/stablesort.py	Sun Dec 10 03:49:48 2017 +0100
@@ -331,10 +331,16 @@
 
     def getjumps(self, repo, rev):
         if rev not in self._jumps:
-            # still won't load anything if rev is not a merge
-            self.get(repo, rev) # we can be smarter here
-            if rev not in self._jumps:
+            parents = repo.changelog.parentrevs(rev)
+            if parents[1] == nodemod.nullrev:
                 self._jumps[rev] = None
+            else:
+                # merge ! warn the cache
+                tiebreaker = _mergepoint_tie_breaker(repo)
+                minparent = sorted(parents, key=tiebreaker)[0]
+                for r in self.walkfrom(repo, rev):
+                    if r == minparent:
+                        break
         return self._jumps[rev]
 
     def walkfrom(self, repo, head):