Patchwork D6262: rust-discovery: using from Python code

login
register
mail settings
Submitter phabricator
Date April 18, 2019, 9:11 a.m.
Message ID <c4fa7bdee4dc8d11ee9ca3011f9dd330@localhost.localdomain>
Download mbox | patch
Permalink /patch/39738/
State Not Applicable
Headers show

Comments

phabricator - April 18, 2019, 9:11 a.m.
gracinet updated this revision to Diff 14837.

REPOSITORY
  rHG Mercurial

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

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,
@@ -372,7 +377,10 @@ 
 
     # full blown discovery
 
-    disco = partialdiscovery(local, ownheads)
+    if rustdisco is not None:
+        disco = rustdisco.PartialDiscovery(local.changelog.index, ownheads)
+    else:
+        disco = partialdiscovery(local, ownheads)
     # treat remote heads (and maybe own heads) as a first implicit sample
     # response
     disco.addcommons(knownsrvheads)