diff mercurial/setdiscovery.py @ 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 d55b71393907
children 6000f5b25c9b
line wrap: on
line diff
--- 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