changeset 41204:e3cfe0702eac

revlog: inline opener options logic into _loadindex() 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. Differential Revision: https://phab.mercurial-scm.org/D5563
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 09 Jan 2019 16:18:00 -0800
parents d0de4fdd87aa
children 3f807237dc94
files mercurial/revlog.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed Jan 09 16:14:09 2019 -0800
+++ b/mercurial/revlog.py	Wed Jan 09 16:18:00 2019 -0800
@@ -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.