Patchwork D6395: rust-dirstate: call new "dirs" rust implementation from Python

login
register
mail settings
Submitter phabricator
Date May 17, 2019, 10:10 a.m.
Message ID <differential-rev-PHID-DREV-agck7npwlujci5nzqlex-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/40110/
State Superseded
Headers show

Comments

phabricator - May 17, 2019, 10:10 a.m.
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a simple module attribute replacement, will take precedence over the
  Python and C implementations.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -53,6 +53,12 @@ 
     stringutil,
 )
 
+try:
+    from . import rustext
+    rustext.__name__  # force actual import (see hgdemandimport)
+except ImportError:
+    rustext = None
+
 base85 = policy.importmod(r'base85')
 osutil = policy.importmod(r'osutil')
 parsers = policy.importmod(r'parsers')
@@ -3204,6 +3210,9 @@ 
 if safehasattr(parsers, 'dirs'):
     dirs = parsers.dirs
 
+if rustext is not None:
+    dirs = rustext.dirstate.Dirs
+
 def finddirs(path):
     pos = path.rfind('/')
     while pos != -1: