rust-index: add a `experimental.rust.index` option to use the wrapper
authorGeorges Racinet <georges.racinet@octobus.net>
Thu, 12 Dec 2019 18:31:17 +0100
changeset 44014 8042856c90b6
parent 44013 992f0d6e7f33
child 44016 1e0783b946c8
rust-index: add a `experimental.rust.index` option to use the wrapper Now we can start putting this wrapper on the test and benchmark grill. Differential Revision: https://phab.mercurial-scm.org/D7660
mercurial/configitems.py
mercurial/localrepo.py
mercurial/revlog.py
--- a/mercurial/configitems.py	Wed Dec 11 18:10:20 2019 +0100
+++ b/mercurial/configitems.py	Thu Dec 12 18:31:17 2019 +0100
@@ -657,6 +657,9 @@
     b'experimental', b'revisions.disambiguatewithin', default=None,
 )
 coreconfigitem(
+    b'experimental', b'rust.index', default=False,
+)
+coreconfigitem(
     b'experimental', b'server.filesdata.recommended-batch-size', default=50000,
 )
 coreconfigitem(
--- a/mercurial/localrepo.py	Wed Dec 11 18:10:20 2019 +0100
+++ b/mercurial/localrepo.py	Thu Dec 12 18:31:17 2019 +0100
@@ -927,6 +927,9 @@
     if repository.NARROW_REQUIREMENT in requirements:
         options[b'enableellipsis'] = True
 
+    if ui.configbool('experimental', 'rust.index'):
+        options[b'rust.index'] = True
+
     return options
 
 
--- a/mercurial/revlog.py	Wed Dec 11 18:10:20 2019 +0100
+++ b/mercurial/revlog.py	Thu Dec 12 18:31:17 2019 +0100
@@ -106,6 +106,7 @@
 parsers = policy.importmod('parsers')
 rustancestor = policy.importrust('ancestor')
 rustdagop = policy.importrust('dagop')
+rustrevlog = policy.importrust('revlog')
 
 # Aliased for performance.
 _zlibdecompress = zlib.decompress
@@ -351,6 +352,12 @@
         return p
 
 
+class rustrevlogio(revlogio):
+    def parseindex(self, data, inline):
+        index, cache = super(rustrevlogio, self).parseindex(data, inline)
+        return rustrevlog.MixedIndex(index), cache
+
+
 class revlog(object):
     """
     the underlying revision storage object
@@ -585,6 +592,8 @@
         self._storedeltachains = True
 
         self._io = revlogio()
+        if rustrevlog is not None and self.opener.options.get('rust.index'):
+            self._io = rustrevlogio()
         if self.version == REVLOGV0:
             self._io = revlogoldio()
         try: