Patchwork D7660: rust-index: add a `experimental.rust.index` option to use the wrapper

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2019, 8:13 p.m.
Message ID <differential-rev-PHID-DREV-xhgliimt2wmwftvl3unb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43816/
State Superseded
Headers show

Comments

phabricator - Dec. 13, 2019, 8:13 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Now we can start putting this wrapper on the test and benchmark grill.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/localrepo.py
  mercurial/revlog.py

CHANGE DETAILS




To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 9, 2020, 1:30 a.m.
mharbison72 added inline comments.

INLINE COMMENTS

> localrepo.py:930
>  
> +    if ui.configbool('experimental', 'rust.index'):
> +        options[b'rust.index'] = True

This needs bytes if someone with write access wants to rewrite it before it gets too deep.  Alternately, I submitted D7817 <https://phab.mercurial-scm.org/D7817>.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7660/new/

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

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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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
@@ -341,6 +342,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
@@ -575,6 +582,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:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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
 
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -654,6 +654,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(