Patchwork D10570: revlog: split the option initialisation in its own method

login
register
mail settings
Submitter phabricator
Date May 3, 2021, 11:53 a.m.
Message ID <differential-rev-PHID-DREV-43lx4ejg676v2srzvizs-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48887/
State New
Headers show

Comments

phabricator - May 3, 2021, 11:53 a.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The part of the code is huge, keeping it separated will keep the `_loadindex`
  method simpler and help keeping logic well insulated.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -363,7 +363,22 @@ 
 
         self._concurrencychecker = concurrencychecker
 
-    def _loadindex(self):
+    def _init_opts(self):
+        """process options (from above/config) to setup associated default revlog mode
+
+        These values might be affected when actually reading on disk information.
+
+        The relevant values are returned for use in _loadindex().
+
+        * newversionflags:
+            version header to use if we need to create a new revlog
+
+        * mmapindexthreshold:
+            minimal index size for start to use mmap
+
+        * force_nodemap:
+            force the usage of a "development" version of the nodemap code
+        """
         mmapindexthreshold = None
         opts = self.opener.options
 
@@ -426,7 +441,12 @@ 
                 _(b'revlog chunk cache size %r is not a power of 2')
                 % self._chunkcachesize
             )
-
+        force_nodemap = opts.get(b'devel-force-nodemap', False)
+        return newversionflags, mmapindexthreshold, force_nodemap
+
+    def _loadindex(self):
+
+        newversionflags, mmapindexthreshold, force_nodemap = self._init_opts()
         indexdata = b''
         self._initempty = True
         try:
@@ -505,7 +525,7 @@ 
 
         devel_nodemap = (
             self.nodemap_file
-            and opts.get(b'devel-force-nodemap', False)
+            and force_nodemap
             and parse_index_v1_nodemap is not None
         )