Patchwork D6262: rust-discovery: using from Python code

login
register
mail settings
Submitter phabricator
Date April 17, 2019, 12:17 p.m.
Message ID <differential-rev-PHID-DREV-mdmlbbhqub67nddzjqxx-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39692/
State Superseded
Headers show

Comments

phabricator - April 17, 2019, 12:17 p.m.
gracinet created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As previously done in other topics, the Rust version is used if it's been
  built.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/setdiscovery.py

CHANGE DETAILS




To: gracinet, #hg-reviewers
Cc: mercurial-devel
phabricator - May 22, 2019, 4:38 p.m.
gracinet added a comment.


  I'm abandoning this revision because I have to resubmit the whole series after partial incorrect application last week and subsequent droping from the actual repo.

REPOSITORY
  rHG Mercurial

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

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,
@@ -318,7 +323,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)