marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will speedup repeated call to the same data. Which can be common when
  warming various cache after adding a revision.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9827

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -418,6 +418,8 @@
         self._filteredrevs = frozenset()
         self._filteredrevs_hashcache = {}
         self._copiesstorage = opener.options.get(b'copies-storage')
+        self._changelogrevision_cache = None
+        self._changelogrevision_key = None
 
     @property
     def filteredrevs(self):
@@ -521,10 +523,14 @@
 
     def changelogrevision(self, nodeorrev):
         """Obtain a ``changelogrevision`` for a node or revision."""
+        if nodeorrev == self._changelogrevision_key:
+            return self._changelogrevision_cache
         text, sidedata = self._revisiondata(nodeorrev)
-        return changelogrevision(
+        cr = changelogrevision(
             text, sidedata, self._copiesstorage == b'changeset-sidedata'
         )
+        self._changelogrevision_cache = cr
+        self._changelogrevision_key = nodeorrev
 
     def readfiles(self, node):
         """



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to