D6262: rust-discovery: using from Python code

gracinet (Georges Racinet) phabricator at mercurial-scm.org
Mon May 6 11:31:07 EDT 2019


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

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)



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


More information about the Mercurial-devel mailing list