revlog: move loading of index data into own method
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 02 Oct 2018 17:28:54 -0700
changeset 40055 0a4625ffd6c0
parent 40054 801ccd8e67c0
child 40056 324b4b10351e
revlog: move loading of index data into own method This will allow us to "reload" a revlog instance from a rewritten index file, which will be used in a subsequent commit. Differential Revision: https://phab.mercurial-scm.org/D4868
mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Oct 03 10:57:35 2018 -0700
+++ b/mercurial/revlog.py	Tue Oct 02 17:28:54 2018 -0700
@@ -415,12 +415,15 @@
             raise error.RevlogError(_('revlog chunk cache size %r is not a '
                                       'power of 2') % self._chunkcachesize)
 
+        self._loadindex(v, mmapindexthreshold)
+
+    def _loadindex(self, v, mmapindexthreshold):
         indexdata = ''
         self._initempty = True
         try:
             with self._indexfp() as f:
                 if (mmapindexthreshold is not None and
-                        self.opener.fstat(f).st_size >= mmapindexthreshold):
+                    self.opener.fstat(f).st_size >= mmapindexthreshold):
                     indexdata = util.buffer(util.mmapread(f))
                 else:
                     indexdata = f.read()