Patchwork [4,of,5] changelog: add way to call the revsbetween C implementation

mail settings
Submitter Laurent Charignon
Date Aug. 7, 2015, 6:10 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/10117/
State Changes Requested
Headers show


Laurent Charignon - Aug. 7, 2015, 6:10 a.m.
# HG changeset patch
# User Laurent Charignon <>
# Date 1438924231 25200
#      Thu Aug 06 22:10:31 2015 -0700
# Branch stable
# Node ID a46abf455540c64f73f7c79dc22ae7f430a3d6d0
# Parent  074dd6f6412076af9704bc9848c97d4c647f330d
changelog: add way to call the revsbetween C implementation

This patch is part of a series of patches to speed up the computation of
revset.revsbetween by introducing a C implementation. The main motivation is to
speed up smartlog on big repositories. At the end of the series, on our big
repositories the computation of revsbetween is 10-50x faster and smartlog on is
2x-5x faster.

This patch allows us to call the new C implementation of revsbetween from
python by creating an entry point in the changelog class.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -7,7 +7,7 @@ 
 from node import bin, hex, nullid
 from i18n import _
-import util, error, revlog, encoding
+import util, error, revlog, encoding, revset
 _defaultextra = {'branch': 'default'}
@@ -172,6 +172,15 @@ 
         return self._nodecache
+    def revsbetween(self, minroot, heads, roots, onlyroots):
+        reachable = self.index.revsbetween(minroot, heads, roots, onlyroots)
+        if reachable is None:
+            # The C code hasn't been able to initialize a list, something went
+            # really wrong, let's rely on the pure implementation in that case
+            raise AttributeError()
+        else:
+            return revset.baseset(sorted(reachable))
     def headrevs(self):
         if self.filteredrevs: