Patchwork D5442: rust-cpython: using the new bindings from Python

login
register
mail settings
Submitter phabricator
Date Jan. 6, 2019, 1:55 a.m.
Message ID <6f2c028054d80e711c29eebd32f94121@localhost.localdomain>
Download mbox | patch
Permalink /patch/37488/
State Not Applicable
Headers show

Comments

phabricator - Jan. 6, 2019, 1:55 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG536c83535cbd: rust-cpython: using the new bindings from Python (authored by gracinet, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5442?vs=13008&id=13015

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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)