changeset 41115:536c83535cbd

rust-cpython: using the new bindings from Python The Python callers detect if we have cpython or direct-ffi bindings and fallback to the Python implementation if none is present. This intermediate state allows to compare the three possibilities. Differential Revision: https://phab.mercurial-scm.org/D5442
author Georges Racinet <gracinet@anybox.fr>
date Thu, 06 Dec 2018 20:04:35 +0100
parents b31a41f24864
children 1205ba8f11ac
files mercurial/revlog.py
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Thu Dec 13 18:53:40 2018 +0100
+++ b/mercurial/revlog.py	Thu Dec 06 20:04:35 2018 +0100
@@ -97,6 +97,11 @@
 REVIDX_RAWTEXT_CHANGING_FLAGS
 
 parsers = policy.importmod(r'parsers')
+try:
+    from . import rustext
+    rustext.__name__  # force actual import (see hgdemandimport)
+except ImportError:
+    rustext = None
 
 # Aliased for performance.
 _zlibdecompress = zlib.decompress
@@ -779,12 +784,17 @@
         for r in revs:
             checkrev(r)
         # and we're sure ancestors aren't filtered as well
-        if util.safehasattr(parsers, 'rustlazyancestors'):
-            return ancestor.rustlazyancestors(
-                self.index, revs,
-                stoprev=stoprev, inclusive=inclusive)
-        return ancestor.lazyancestors(self._uncheckedparentrevs, revs,
-                                      stoprev=stoprev, inclusive=inclusive)
+
+        if rustext is not None:
+            lazyancestors = rustext.ancestor.LazyAncestors
+            arg = self.index
+        elif util.safehasattr(parsers, 'rustlazyancestors'):
+            lazyancestors = ancestor.rustlazyancestors
+            arg = self.index
+        else:
+            lazyancestors = ancestor.lazyancestors
+            arg = self._uncheckedparentrevs
+        return lazyancestors(arg, revs, stoprev=stoprev, inclusive=inclusive)
 
     def descendants(self, revs):
         return dagop.descendantrevs(revs, self.revs, self.parentrevs)