Patchwork D6262: rust-discovery: using from Python code

login
register
mail settings
Submitter phabricator
Date May 6, 2019, 3:31 p.m.
Message ID <c7d854cf630c6eff6a6fe12096a2f7dd@localhost.localdomain>
Download mbox | patch
Permalink /patch/39968/
State Not Applicable
Headers show

Comments

phabricator - May 6, 2019, 3:31 p.m.
gracinet updated this revision to Diff 15026.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6262?vs=14837&id=15026

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

AFFECTED FILES
  mercurial/setdiscovery.py

CHANGE DETAILS




To: gracinet, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -46,6 +46,11 @@ 
 import random
 
 from .i18n import _
+try:
+    from .rustext import discovery as rustdisco
+except ImportError:
+    rustdisco = None
+
 from .node import (
     nullid,
     nullrev,
@@ -387,8 +392,11 @@ 
     # full blown discovery
 
     randomize = ui.configbool('devel', 'discovery.randomize')
-    disco = partialdiscovery(local, ownheads, randomize=randomize)
-
+    if rustdisco is not None:
+        disco = rustdisco.PartialDiscovery(local.changelog.index, ownheads,
+                                           randomize=randomize)
+    else:
+        disco = partialdiscovery(local, ownheads, randomize=randomize)
     # treat remote heads (and maybe own heads) as a first implicit sample
     # response
     disco.addcommons(knownsrvheads)