Patchwork D9828: changelog: use revision number as the cache key internally

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2021, 6:11 p.m.
Message ID <differential-rev-PHID-DREV-c32odiu2zb6k2xxyak2y-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48138/
State New
Headers show

Comments

phabricator - Jan. 18, 2021, 6:11 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This allow both rev and node request to match the cache.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -523,9 +523,14 @@ 
 
     def changelogrevision(self, nodeorrev):
         """Obtain a ``changelogrevision`` for a node or revision."""
-        if nodeorrev == self._changelogrevision_key:
+        if not isinstance(nodeorrev, int):
+            rev = self.rev(nodeorrev)
+        else:
+            rev = nodeorrev
+
+        if rev == self._changelogrevision_key:
             return self._changelogrevision_cache
-        text, sidedata = self._revisiondata(nodeorrev)
+        text, sidedata = self._revisiondata(rev)
         cr = changelogrevision(
             text, sidedata, self._copiesstorage == b'changeset-sidedata'
         )