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

mail settings
Submitter Laurent Charignon
Date Aug. 7, 2015, 5:38 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/10138/
State Changes Requested
Headers show


Laurent Charignon - Aug. 7, 2015, 5:38 p.m.
# HG changeset patch
# User Laurent Charignon <>
# Date 1438924231 25200
#      Thu Aug 06 22:10:31 2015 -0700
# Branch stable
# Node ID 3e52fa2d5b5dfa082f87b4cee52d3580c97833ff
# Parent  cf26c47bd9344439d5b97b42df7d64330468c5c6
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, includepath):
+        reachable = self.index.revsbetween(minroot, heads, roots, includepath)
+        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: