changeset 47280:6be2a7ca4b1d

revlog: do not call Rust code if the index is not compatible with it This will avoid hitting the TypeError we defined in the previous changesets. This is the simplest fix but not the most elegant. Ideally we would teach the Rust code to use any kind of revlog. However this is an adventure for another time. Differential Revision: https://phab.mercurial-scm.org/D10666
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 04 May 2021 14:18:06 +0200
parents 9d1a8829f959
children 25ce16bf724b
files mercurial/revlog.py mercurial/setdiscovery.py
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue May 04 14:16:26 2021 +0200
+++ b/mercurial/revlog.py	Tue May 04 14:18:06 2021 +0200
@@ -1063,7 +1063,7 @@
             checkrev(r)
         # and we're sure ancestors aren't filtered as well
 
-        if rustancestor is not None:
+        if rustancestor is not None and self.index.rust_ext_compat:
             lazyancestors = rustancestor.LazyAncestors
             arg = self.index
         else:
@@ -1150,7 +1150,7 @@
         if common is None:
             common = [nullrev]
 
-        if rustancestor is not None:
+        if rustancestor is not None and self.index.rust_ext_compat:
             return rustancestor.MissingAncestors(self.index, common)
         return ancestor.incrementalmissingancestors(self.parentrevs, common)
 
@@ -1370,7 +1370,7 @@
                 return self.index.headrevs()
             except AttributeError:
                 return self._headrevs()
-        if rustdagop is not None:
+        if rustdagop is not None and self.index.rust_ext_compat:
             return rustdagop.headrevs(self.index, revs)
         return dagop.headrevs(revs, self._uncheckedparentrevs)
 
--- a/mercurial/setdiscovery.py	Tue May 04 14:16:26 2021 +0200
+++ b/mercurial/setdiscovery.py	Tue May 04 14:18:06 2021 +0200
@@ -274,6 +274,8 @@
         return sample
 
 
+pure_partialdiscovery = partialdiscovery
+
 partialdiscovery = policy.importrust(
     'discovery', member='PartialDiscovery', default=partialdiscovery
 )
@@ -434,9 +436,11 @@
     hard_limit_sample = not (dynamic_sample or remote.limitedarguments)
 
     randomize = ui.configbool(b'devel', b'discovery.randomize')
-    disco = partialdiscovery(
-        local, ownheads, hard_limit_sample, randomize=randomize
-    )
+    if cl.index.rust_ext_compat:
+        pd = partialdiscovery
+    else:
+        pd = pure_partialdiscovery
+    disco = pd(local, ownheads, hard_limit_sample, randomize=randomize)
     if initial_head_exchange:
         # treat remote heads (and maybe own heads) as a first implicit sample
         # response