changeset 48946:6ea9ead59cf8

revlog: use rust rank computation if available Differential Revision: https://phab.mercurial-scm.org/D12212
author pacien <pacien.trangirard@pacien.net>
date Mon, 21 Feb 2022 16:18:39 +0100
parents 8b8054b8e5a7
children 078e1e1cc7da
files mercurial/revlog.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon Feb 21 16:18:06 2022 +0100
+++ b/mercurial/revlog.py	Mon Feb 21 16:18:39 2022 +0100
@@ -2471,9 +2471,12 @@
             elif p1r == nullrev and p2r != nullrev:
                 rank = 1 + self.fast_rank(p2r)
             else:  # merge node
-                pmin, pmax = sorted((p1r, p2r))
-                rank = 1 + self.fast_rank(pmax)
-                rank += sum(1 for _ in self.findmissingrevs([pmax], [pmin]))
+                if rustdagop is not None and self.index.rust_ext_compat:
+                    rank = rustdagop.rank(self.index, p1r, p2r)
+                else:
+                    pmin, pmax = sorted((p1r, p2r))
+                    rank = 1 + self.fast_rank(pmax)
+                    rank += sum(1 for _ in self.findmissingrevs([pmax], [pmin]))
 
         e = revlogutils.entry(
             flags=flags,