D5563: revlog: inline opener options logic into _loadindex()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Fri Jan 11 00:33:57 UTC 2019


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We always call _loadindex() during __init__. But we also call
  _loadindex() as part of censorrevision(). Before, when reloading
  the index during censorrevision(), we would lose the configured
  mmapindexthreshold setting from the opener. By inlining the
  logic in _loadindex(), we ensure that opener options are always
  respected when loading the index.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -384,8 +384,11 @@
         # 2-tuple of file handles being used for active writing.
         self._writinghandles = None
 
+        self._loadindex()
+
+    def _loadindex(self):
         mmapindexthreshold = None
-        opts = getattr(opener, 'options', {}) or {}
+        opts = getattr(self.opener, 'options', {}) or {}
 
         if 'revlogv2' in opts:
             versionflags = REVLOGV2 | FLAG_INLINE_DATA
@@ -431,9 +434,6 @@
             raise error.RevlogError(_('revlog chunk cache size %r is not a '
                                       'power of 2') % self._chunkcachesize)
 
-        self._loadindex(versionflags, mmapindexthreshold)
-
-    def _loadindex(self, versionflags, mmapindexthreshold):
         indexdata = ''
         self._initempty = True
         try:
@@ -2499,7 +2499,7 @@
             self.opener.rename(newrl.datafile, self.datafile)
 
         self.clearcaches()
-        self._loadindex(self.version, None)
+        self._loadindex()
 
     def verifyintegrity(self, state):
         """Verifies the integrity of the revlog.



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list